OpenCV 2.4.3+ with libstdc ++ for iOS?

I am trying to incorporate a recent version of OpenCV into an existing iOS project and I am having linker errors because my XCode project uses libstdC ++ and not libC ++ / C ++ 11 support.

I saw several other people who corrected their errors by turning on libC ++. Examples:

  • Linker Errors After Upgrading Xcode to 4.5.2 and OpenCV to 2.4.3
  • How to resolve iOS Link errors with OpenCV

However, I NEED to use libstdC ++, because I have other third-party libraries that are already compiled with the old stdlib (cannot be changed). Is there a way to compile OpenCV 2.4.3+ without -stdlib = libC ++? Are there special flags for CMake? or in the build_framework.py script file, which is included in the iC folder of the OpenCV source code?

Alternatively, does anyone have a binary version available? It seems that all downloads from OpenCV assume libC ++ / C ++ 11.

+5
c ++ ios c ++ 11 xcode opencv
Apr 6 '13 at
source share
2 answers

In the source for openCV, find 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 python script

 ios/build_framework.py 

Then you should be good to go

I just tried this in source 2.4.3, changed in the resulting structure of an existing project, changed the standard C ++ library for the project to libstdC ++, and it works fine.

+10
Apr 7 '13 at 1:01
source share

I am also working on a project using OpenCV and a third-party library that requires libstdC ++.

As I myself ran into this problem, I wanted to share what worked for me.




I managed to start OpenCV by adding the lib ++ project to the project. dylib.

Assembly phases → "Link to binary files with libraries" → "+" → lib ++. dylib

For reference, I am using OpenCV 2.4.9 (opencv-2.4.9) from opencv.org. I compiled it using the ios platform build_framework.py according to the instructions in the OpenCV docs. No changes are required.

+1
Apr 27 '14 at 13:06 on
source share



All Articles