How to resolve iOS Link errors with OpenCV

坚强是说给别人听的谎言 提交于 2019-12-17 19:32:23

问题


I'm trying to add the newest version of openCV to my iOS project, but when I compile, I get about 30 link errors:

Example:

Undefined symbols for architecture i386:
"cv::merge(std::vector<cv::Mat, std::allocator<cv::Mat> > const&, cv::_OutputArray const&)", referenced from:

I added the OpenCV framework, along with all the other required frameworks, in a dummy app with a simple video capture (following the tutorial in the link), and it worked perfectly.

I'm not sure why it could have worked so smoothly in one place, but not in the other. My only thought is that I ame compiling for different architectures between the two apps, but I think for both I'm aiming at armv7 and armv7s.

Any idea on what could be causing link errors?


回答1:


Check this: (assuming you are using LLVM compiler)

Target > Build Settings > Apple LLVM Compiler 4.1 - language > C++ Standard Library
try selecting

libstdc++ (GNU C++ standard library)`  

then try switch to

libc++ (LLVM C++ standard library with C++11 support)

libstdc++ seems to work for older builds of openCV, libc++ correct for newer builds. If you have it set wrong (either way) you will see these kinds of errors.

If that isn't the cause, open the build setting side by side in each project and check every setting...

I have been battling through this recently - see my question here, answers here and github sample here. The github project includes opencv framework compiled from current source a few days ago. Right now I am putting together a multi-target sample that links to a different version of the framework if compiling under 10.6/XCode4.2 or 10.7/XCode4.4+. [On github here]

update

As @mikewoz requested, you may need to run current openCV with libstdc++ to remain compatible with other frameworks. It is possible to make a current build with libstdc++ compatibility. For details see my answer to Mike's question here:

OpenCV 2.4.3+ with libstdc++ for iOS?



来源:https://stackoverflow.com/questions/14185716/how-to-resolve-ios-link-errors-with-opencv

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!