Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV build issue, can't find ext/atomicity.h

Tags:

xcode

ios

opencv

I get the compiler error complaining about <ext/atomicity.h> when building a project incorporating OpenCV. Environment is Xcode 4.5 targeting iOS. It compiles fine for the simulator but fails when building for the device. Here's the error text:

/Users/Nick/projects/ios/opencv2.framework/Headers/core/operations.hpp:65:16: fatal error: 'ext/atomicity.h' file not found
      #include <ext/atomicity.h>

I'm using the opencv2.framework, builusing cmake, using the instructions here.

like image 885
TomSwift Avatar asked Oct 23 '12 19:10

TomSwift


2 Answers

By default XCode 4.5 generates new projects to build using the libc++ (LLVM C++ standard library with C++ 11 support). But OpenCV is expecting to be built against the GNU libstdc++ (GNU C++ standard library). <ext/atomicity.h> is apparently a GNU extension and isn't part of the LLVM libc++ standard library.

In your project's target settings, select libstdc++ (GNU C++ standard library) for the C++ Standard Library setting.

Very likely the atomicity.h requirement could be factored out of opencv or otherwise done in a LLVM libc++ compatible way. I didn't explore this but would be interested if anyone had insight on how this could be done.

like image 184
TomSwift Avatar answered Oct 01 '22 22:10

TomSwift


I think it is the other way around. Looking at the output of the python script that builds opencv2.framework I get this:

-- C++ flags (Release): -stdlib=libc++ -headerpad_max_install_names -fvisibility=hidden -fvisibility-inlines-hidden -fPIC -DNDEBUG -O3 [...]

which is most likely not what you want. So you need to compile the framework with libstdc++ or compile your app with the proper lib. From what I see I get problems when building my apps with libc++ but that might be me.

like image 28
Pierre Fite Georgel Avatar answered Oct 01 '22 22:10

Pierre Fite Georgel