简体   繁体   中英

Error while compiling iOS app with openCV framework on real device

With latest open cv framework i am unable to compile code on IOS device. i am facing following error.

Undefined symbols for architecture arm64: "_png_init_filter_functions_neon", referenced from: _png_read_filter_row in opencv2(pngrutil.o) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Same app is able to compile for simulator but not for ios devices. Can any one tell me why i am facing this problem. Thanks in advance.

我已经解决了这个问题。这个问题的核心是我们重新编译了libpng中的某些内容,也许它在其他ios框架中退出了。然后发生了冲突。Opncv3.1的代码中包含3rdparty。您应该做的是查找行117-121在libpng的pngpriv.h中,然后跟随Iphone-device-linker错误

It appears that this commit fixes the issue, while still keeping NEON support for iOS devices:

https://github.com/opencv/opencv/commit/262a52f3063c50fbb1236e2cba2bd3c68f9979bb

Essentially, the clause that appends -DENABLE_NEON=ON to the cmake line was only applying to architectures beginning with "armv" (note the "v"); the above commit changes opencv/platforms/ios/build_framework.py to allow the cmake command to work with "arm64" as well.

Before:

    if arch.startswith("armv"):
        cmakecmd.append("-DENABLE_NEON=ON")

After:

    if arch.startswith("armv") or arch.startswith("arm64"):
        cmakecmd.append("-DENABLE_NEON=ON")

Diagnostic process, since it might be useful:

Found this by starting a script build.log before invoking python ../opencv/platforms/ios/build_framework.py ios and digging through output; arm_init.c was not built for arm64 (which is where png_init_filter_functions_neon was defined) but was for armv7 and armv7s . From there, looking through 3rdparty/libpng/CMakeLists.txt pointed at ENABLE_NEON not being set.

I faced the same problem as @shahzaib described. In simulator it works but in iPhone its not working and showing the same error.

Previously I manually added OpenCV 3.1 in my iOS project. Later I changed it and install the OpenCV library via cocoapod https://cocoapods.org/pods/OpenCV

And in cocoapod there is 3.1.0.1 version which fixed the issue.

  pod 'OpenCV', '~> 3.1.0.1'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM