Reputation: 13986
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?
Upvotes: 2
Views: 4527
Reputation: 31745
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?
Upvotes: 13