6

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.

Shripada
  • 6,296
  • 1
  • 30
  • 30
shahzaib
  • 75
  • 2
  • 9
  • You have to know that simulator is the simulator, and the real device is different. Your error log clearly says that the library your are using is not compiled for the 64 bit devices. – Fahri Azimov Feb 11 '16 at 11:56
  • I don't know where from you got `opencv`, but 64 bit is supported by default on the latest `opencv` framework, get it from - http://opencv.org/downloads.html – Fahri Azimov Feb 11 '16 at 12:04
  • 4
    @FahriAzimov thanks for the reply. I know about differences and error. Yes i download from same place. 3.0 is working fine but 3.1 have this problem. – shahzaib Feb 11 '16 at 12:09
  • Hi guy's I also have the same problem opencv framwork version 3.1 not archiving app on other side we can debug and test on real device but not able to archive the app. does any one know what goes wrong or I'm I doing it wrong ? – Rahul Shirphule Feb 16 '16 at 12:36
  • @RahulShirphule You have to download code for github and recompile it with enabling it for 64 bit devices. I have not tired by my self and also do not know why open CV developer have not did it yet. – shahzaib Feb 17 '16 at 05:56
  • @shahzaib: done and I still get this error ... – Goz Mar 24 '16 at 15:08
  • This is awesomely strange. Same here. Version 3.0 works but 3.1 does not. – Lukas Mar 26 '16 at 17:26
  • @Goz did enable 64 bit arc before compiling in cmake file ? https://github.com/Itseez/opencv/blob/master/platforms/ios/cmake/Modules/Platform/iOS.cmake#L89 – shahzaib Mar 28 '16 at 06:04
  • @Goz Follow this link http://stackoverflow.com/questions/18976893/how-to-compile-opencv-for-ios7-arm64. One more thing is that OpenCV version 3.1 and 3.0 is same for IOS. – shahzaib Mar 28 '16 at 06:13

3 Answers3

2

I had fixed this problem.The core of this problem is that we recompile some content in libpng,maybe it exits in other ios framework.Then it makes a conflict.Opncv 3.1 has 3rdparty in it's code.What you should do is find the lines 117-121 in libpng's pngpriv.h.Then just follow Iphone - device - linker error.

Community
  • 1
  • 1
MLB
  • 36
  • 2
2

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.

leander
  • 8,527
  • 1
  • 30
  • 43
1

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'
Mahmud Ahsan
  • 1,755
  • 19
  • 18