Qt 5.1 Beta版错误使用std::atomic c++11特性

Qt 5.1 Beta Error using std::atomic c++11 feature

本文关键字:std atomic c++11 特性 Beta 错误 Qt      更新时间:2023-10-16

我刚刚开始使用QT,我仍然熟悉编译过程。目前,我正试图将现有的QT项目移植到Mac。此应用程序可在Linux和Windows上编译和运行。

当我在Mac OSX 10.8.2上编译项目时,我得到了这个c++11相关的错误,

#include ../xxx/pch.h:71:10: fatal error: 'atomic' file not found
#include <atomic>
^
1 error generated.
make[1]: *** [debug/xxx/objective-c++.pch] Error 1
make: *** [debug] Error 2
11:32:01: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project xxx (kit: Qt5.1.0)
When executing step 'Make'

中包含了以下标志。支持c++11,

QMAKE_CXXFLAGS += -std=c++11
CONFIG += c++11

我正在使用预构建的QT5.1Beta包(Clang)构建项目,我相信它已经启用了c++11。

我在下面的位置看到了原子头/应用程序/xcode/内容/开发/工具链/XcodeDefault.xctoolchain/usr/lib/c++/v1/原子在/usr/lib/c++/v1/atomic

我试过包含完整路径的测试,/应用程序/xcode/内容/开发/工具链/XcodeDefault.xctoolchain/usr/lib/c++/v1/原子

我得到下面的错误,

In file included from ../xxx/pch.h:71:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/atomic:535:2: 
error: atomic is not implemented
In file included from ../xxx/pch.h:124:
../../../yyy.h:308:12: error: no type named 'atomic' in namespace 'std'
std::atomic<bool> m_signaled;

我在这里错过了什么?

Add also

macx:QMAKE_CXXFLAGS += -stdlib=libc++
macx:QMAKE_LFLAGS += -stdlib=libc++

也许是有点晚了,但我使用-std=gnu++0x标志

修复了它