I'm trying to include a recent version of OpenCV into an existing iOS project and am having linker errors because my XCode project is set to use libstdc++ and not libc++ / C++ 11 support.
I have seen several other people who have fixed their errors by enabling libc++. Examples:
However, I NEED to use libstdc++ because I have other 3rd party libraries which are already compiled with the older stdlib (can't be changed). Is there a way to compile OpenCV 2.4.3+ without -stdlib=libc++ ? Are there special flags to pass to CMake? or to the build_framework.py script that comes in the ios folder of the OpenCV source code?
Alternatively, does anyone have a binary version available? It seems all downloadable from OpenCV assume libc++ / C++11.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With