Error compiling iOS application with openCV framework on a real device

With the last open cv structure, I cannot compile code on an iOS device. I ran into the following error.

Undefined characters for arm64 architecture: "_png_init_filter_functions_neon" referenced: _png_read_filter_row in opencv2 (pngrutil.o) ld: character not found for arm64 architecture clang: error: linker command did not work with exit code 1 (use -v to call the call)

The same application can be compiled for a simulator, but not for ios devices. Can someone tell me why I came across this problem. Thank you in advance.

+5
source share
3 answers

I fixed this problem. The core of this problem is that we recompile some content into libpng, maybe it goes to another ios infrastructure. Then it creates a conflict. Opncv 3.1 has 3rdparty code in it. What you should do is find lines 117-121 in libpng pngpriv.h. Then just follow Iphone - device error - linker .

+2
source

This fix seems to fix the issue, while still maintaining NEON support for iOS devices:

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

Essentially, the sentence adding -DENABLE_NEON=ON to the cmake line only applies to architectures starting with "armv" (note the "v"); the above commit modifies opencv/platforms/ios/build_framework.py so that the cmake command can work with "arm64" .

Before:

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

After:

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

The diagnostic process, as it may be useful:

This was discovered by running the script build.log before calling python ../opencv/platforms/ios/build_framework.py ios and digging up the result; arm_init.c not created for arm64 (where png_init_filter_functions_neon was defined), but was for armv7 and armv7s . From there, browsing 3rdparty/libpng/CMakeLists.txt , pointing to ENABLE_NEON not installed.

+2
source

I ran into the same problem as described by @shahzaib. It works in the simulator, but on the iPhone it does not work and shows the same error.

I used to manually add OpenCV 3.1 to my iOS project. Later I changed it and installed the OpenCV library through cocoapod https://cocoapods.org/pods/OpenCV

And in cocoapod there is version 3.1.0.1 that fixed the problem.

  pod 'OpenCV', '~> 3.1.0.1' 
+1
source

Source: https://habr.com/ru/post/1242770/


All Articles