lundi 30 juillet 2012

OpenCV and CLang / C++ 2011 on mac os x


OpenCV cannot be used in a project using C++11.
I am on mac os x and the new default compiler is CLang.

The issue is that the stdlib for c++11 is "libc++ with c++11 support" but this is not the default one.

solution: compiling OpenCV with CLang and libc++

so how to do it?

cmake ../  -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-stdlib=libc++"

but there is one (small) issue:
OpenCV-2.4.2/modules/ts/include/opencv2/ts/ts_gtest.h uses std:tr1:tuple and it will generate an compiler error.

solution: edit this file and add on the first line:
#define GTEST_USE_OWN_TR1_TUPLE 1

then it will work ! you should be able to use C++2011 in your project using OpenCV on mac os x

BTW my opencv version is 2.4.2



Aucun commentaire:

Enregistrer un commentaire