I used Qt 5.7 and gcc 4.9.2. Qt Core module throw Qt requires C++11 support
error.
This page say that
gcc 4.9.2 fails to compile Qt.
So I installed gcc 4.8. I check using below command on terminal :
$ g++ --version
g++ (Ubuntu 4.8.4-1ubuntu15) 4.8.4
My kit uses cmake not qmake. I add TARGET_LINK_LIBRARIES ( xxxx yyyy /usr/bin/c++ -std=c++11
to CMakeLists-txt.
I restart my pc and run my application again. Same error is throwed.
/opt/Qt/5.7/gcc_64/include/QtCore/qbasicatomic.h:61: error: #error "Qt requires C++11 support"
# error "Qt requires C++11 support"
^
How can I solve it?
Its has been a while.
How I finally solve it is indicating in CMakeLists.txt the following line just after project(MyProject)
:
add_compile_options(-std=c++11)
That says to cmake, to create a Makefile that will use c++11 solving issues.
If using QtCreator, you can add this to your .pro
file:
CONFIG += c++11
https://wiki.qt.io/How_to_use_C%2B%2B11_in_your_Qt_Projects
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With