Ask Your Question
0

Specify libc++ when compiling/linking OpenCV for MacOSX 10.8

asked 2014-03-21 10:14:03 -0600

samduke474 gravatar image

updated 2014-03-21 10:14:37 -0600

I'm trying to set up an automated build system for OpenCV 2.4.8 (downloaded from the OpenCV site) to link it into a parent project. I'm roughly following the instructions for building here: https://sites.google.com/site/yonasstephenfyp2013/updates/tutorialinstallingopencvonmacosxmountainlion

Unfortunately my build machine is running MacOSX 10.8 and I am running 10.9 locally and it seems the default clang C++ library has changed between the two from libstdc++ (see here: http://stackoverflow.com/questions/19637164/c-linking-error-after-upgrading-to-mac-os-x-10-9-xcode-5-0-1)

My parent project is set to use libc++ (this is configured in XCode). Combined with the clang default of libc++ on 10.9 this works fine on my machine. BUT it's causing a bunch of linker errors on my build machine basically not finding the std library). I would therefore like to tell OpenCV to build with libc++. Is there any way of doing this with CMake options?? I have tried passing DCMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY="libc++" -DCMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD="c++0x" -DCLANG_CXX_LIBRARY="libc++" -DCLANG_CXX_LANGUAGE_STANDARD="c++0x" but CMake informs me these are ignored:

CMake Warning:
[13:54:00][OpenCV-Mac-Static-Libs (BUILD)]   Manually-specified variables were not used by the project:
[13:54:00][OpenCV-Mac-Static-Libs (BUILD)]     CLANG_CXX_LANGUAGE_STANDARD
[13:54:00][OpenCV-Mac-Static-Libs (BUILD)]     CLANG_CXX_LIBRARY
[13:54:00][OpenCV-Mac-Static-Libs (BUILD)]     CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD
[13:54:00][OpenCV-Mac-Static-Libs (BUILD)]     CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY

Is there any other way I can fix this? Perhaps changing the CXX_COMPILER_FLAGS??

I don't think switching the project to libstdc++ will work either - I don't think I'll be able to build it locally on my machine then.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2014-03-21 14:53:07 -0600

samduke474 gravatar image

answer was the following flags to cmake -DCMAKE_CXX_FLAGS="-std=c++11 -stdlib=libc++" -DCMAKE_EXE_LINKER_FLAGS="-std=c++11 -stdlib=libc++"

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-03-21 10:14:03 -0600

Seen: 2,680 times

Last updated: Mar 21 '14