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

╄→гoц情女王★ 提交于 2019-12-23 20:52:40

问题


I have just started to work with QT and am still getting familiar with the compilation process. Currently, I am trying to port an existing QT project to Mac. This app compiles and runs on Linux and Windows.

When I compile the project on Mac OSX 10.8.2 , I am getting this c++11 related error ,

#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'

I have included the below flags in the.pro file to enable c++11 ,

QMAKE_CXXFLAGS += -std=c++11

CONFIG += c++11

I am building the project with the pre-built QT5.1Beta package (Clang) which I believe has c++11 enabled.

I see the atomic header in the below locations /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1/atomic and in /usr/lib/c++/v1/atomic

I tried testing by including the complete path , /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr//lib/c++/v1/atomic

I am getting the below error,

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;

What am I missing here?


回答1:


Add also

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



回答2:


Maybe it is a bit late, but I fixed it using the -std=gnu++0x flag



来源:https://stackoverflow.com/questions/16782776/qt-5-1-beta-error-using-stdatomic-c11-feature

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!