How to Resolve iOS Link Errors with Opencv

How to resolve iOS Link errors with OpenCV

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?

Linker errors after upgrading Xcode to 4.5.2 and OpenCV to 2.4.3

Since I can't seem to get an answer regarding the versions (neither here nor at the OpenCV Q&A site), I'm going to post this as an answer, as it at least solved the issue. This is described here.



In your project's Build Settings, go down to the section Apple LLVM compiler 4.1-Language.

There:

Set C++ Language Dialect to Compiler Default

Set C++ Standard Libray to libc++ (LLVM C++ standard libray with C++ 11 support



After doing the above, I stopped getting those linker errors, and only got one error instead, which stated that only iOS 5 and above is supported. Changing the Deployment Target to 5.0 in the project summery did the trick.



On a final note, I'm still not sure what it means, regarding OpenCV 2.4.3's compatibility with iOS versions older than 5.

openCV 2.4.8 iOS 7.0 framework linker errors

Hey I did get it to work, I just had to add the other frameworks that were required to get it to build. You can find them on this page : http://docs.opencv.org/doc/tutorials/ios/video_processing/video_processing.html#opencviosvideoprocessing

Apple O-Linker Error when try to use OpenCV framework in already working project

Your project is linked against libstd++ (GNU C++ standard library), but latest OpenCV was linked against libc++ (LLVM C++ standard library with C++ 11 support), so you have two ways to fix this:

  1. Link you project against libc++
  2. Rebuild OpenCV with libstd++.

To link your project with libc++, go to -> Build Settings -> find 'C++ standard library' row and select libc++ there.

OpenCV 2.4.3+ with libstdc++ for iOS?

In the source for openCV locate this file:

ios/cmake/Modules/Platform/iOS.cmake

Change this line:

set (CMAKE_CXX_FLAGS "-stdlib=libc++ -headerpad_max_install_names -fvisibility=hidden -fvisibility-inlines-hidden")

to:

set (CMAKE_CXX_FLAGS "-stdlib=libstdc++ -headerpad_max_install_names -fvisibility=hidden -fvisibility-inlines-hidden")

Compile using the python script

ios/build_framework.py

Then you should be good to go

I have just tried this on 2.4.3 source, swapped in the resulting framework on an existing project, changed the C++ standard library for the project to libstdc++ and it runs fine.

How to use OpenCV in iOS?

Here's how to fix it...

  • Google your error: "xcrun error: could not stat active Xcode path"
  • Click on the first link and go to

    xcrun: Error: could not stat active Xcode path '/Volumes/Xcode/Xcode45-DP1.app/Contents/Developer'. (No such file or directory)
  • if still unclear try the next couple of links

    change xcrun developer path

    Resolved: Error “Could not stat active Xcode path”

When Google and SO fail you, come back here explaining what you have tried (and post your text errors as text not image!)

As regards your linker error (what linker error? post it!) my answer here might help

How to resolve iOS Link errors with OpenCV

Apple Mach-O Linker (ld) Error Group when OpenCV is added to the library; possible fix?

It’s not enough just to link libraries in Xcode. You need to add the libraries into the projects. To do so, go to /usr/local/libs and drags them to the project explorer (the left panel of Xcode) and choose to create references on the pop up window. You can uncheck the option copy if needed on that window to avoid unnecessary clones of the libraries.



Related Topics



Leave a reply



Submit