Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt requires C++11 support

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?

like image 671
zakjma Avatar asked Sep 05 '16 17:09

zakjma


2 Answers

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.

like image 60
César HM Avatar answered Oct 12 '22 18:10

César HM


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

like image 21
NuclearPeon Avatar answered Oct 12 '22 18:10

NuclearPeon