xcode OpenCV 构建问题,找不到 ext/atomicity.h

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13037659/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 01:54:33  来源:igfitidea点击:

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

iosxcodeopencv

提问by TomSwift

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:

<ext/atomicity.h>在构建包含 OpenCV 的项目时,我收到编译器错误的抱怨。环境是针对 iOS 的 Xcode 4.5。它为模拟器编译良好,但在为设备构建时失败。这是错误文本:

/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.

我正在使用 opencv2.framework,构建 cmake,使用这里的说明。

回答by TomSwift

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.

默认情况下,XCode 4.5 使用libc++ (LLVM C++ standard library with C++ 11 support). 但是 OpenCV 预计是针对 GNU 构建的libstdc++ (GNU C++ standard library)<ext/atomicity.h>显然是 GNU 扩展,而不是 LLVM libc++ 标准库的一部分。

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

在项目的目标设置中,选择libstdc++ (GNU C++ standard library)C++ 标准库设置。

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.

很可能 atomicity.h 要求可以从 opencv 中分解出来,或者以 LLVM libc++ 兼容的方式完成。我没有探索这个,但如果有人对如何做到这一点有深入的了解,我会很感兴趣。

回答by Pierre Fite Georgel

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

我认为情况正好相反。查看构建 opencv2.framework 的 python 脚本的输出,我得到了这个:

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

-- C++ 标志(发布):-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.

这很可能不是您想要的。因此,您需要使用 libstdc++ 编译框架或使用适当的 lib 编译您的应用程序。从我所见,我在使用 libc++ 构建应用程序时遇到了问题,但那可能是我。