How to install qmake in C ++ 14 with recent MinGW?

I know there are duplicates .

This is my Test.pro:

CONFIG += c++14 SOURCES += main.cpp 

and my main.cpp:

 int main(){} 

For many duplicates, this should give me C ++ 14. However, when I create a project with Qt Creator 4.2.0 with Qt 5.8.0-1 and MinGW gcc 5.3.0-1 through the maintenance tool I get

g ++ -c -pipe -fno-keep-inline-dllexport -g -std = gnu ++ 1y -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQTIN_MQ_IN . -IC: \ Qt \ 5.8 \ mingw53_32 \ include -IC: \ Qt \ 5.8 \ mingw53_32 \ include \ QtGui -IC: \ Qt \ 5.8 \ mingw53_32 \ include \ QtANGLE -IC: \ Qt \ 5.8 \ mingw53_32 \ include \ QtCore -Idebug -IC: \ Qt \ 5.8 \ mingw53_32 \ mkspecs \ win32-g ++ -o debug \ main.o .. \ Test \ main.cpp

which is not -std=c++14 , I expect.

I tried all kinds of tricks from other questions such as

 QMAKE_CXXFLAGS_CXX14 = -std=c++14 CONFIG += c++14 QMAKE_CXXFLAGS += -std=c++14 SOURCES += main.cpp 

that leads to

g ++ -c -pipe -fno-keep-inline-dllexport -std = C ++ 14 -g -std = gnu ++ 1y -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG -DQT_GUI_LIB -DQT_QT_CT_QT_CT_CT_CT_CT_CT_CT_CT_CT_CT_CT_CTL_CT_CT_CTL_CT_CT_CTLD I .. \ Test -I. -IC: \ Qt \ 5.8 \ mingw53_32 \ include -IC: \ Qt \ 5.8 \ mingw53_32 \ include \ QtGui -IC: \ Qt \ 5.8 \ mingw53_32 \ include \ QtANGLE -IC: \ Qt \ 5.8 \ mingw53_32 \ include \ QtCore -Idebug -IC: \ Qt \ 5.8 \ mingw53_32 \ mkspecs \ win32-g ++ -o debug \ main.o .. \ Test \ main.cpp

where the second parameter overwrites the first, that is, it is still in gnu++1y -mode or just

 QMAKE_CXXFLAGS += -std=c++14 SOURCES += main.cpp 

which also leads to

g ++ -c -pipe -fno-keep-inline-dllexport -std = C ++ 14 -g -std = gnu ++ 11 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG -DQT_GUI_LIB -DQT_DQT_IBE_IBE_BORE I .. \ Test -I. -IC: \ Qt \ 5.8 \ mingw53_32 \ include -IC: \ Qt \ 5.8 \ mingw53_32 \ include \ QtGui -IC: \ Qt \ 5.8 \ mingw53_32 \ include \ QtANGLE -IC: \ Qt \ 5.8 \ mingw53_32 \ include \ QtCore -Idebug -IC: \ Qt \ 5.8 \ mingw53_32 \ mkspecs \ win32-g ++ -o debug \ main.o .. \ Test \ main.cpp

I deleted the assembly directory and the Test.pro.user file to force the assembly from scratch, nothing gave me C ++ 14.

How to tell qmake to use C ++ 14?

+1
c ++ qt qmake
source share
1 answer

In the version of Qt that you are using, I do not explicitly support the compiler you are using. You can do one of the following:

  • Set both QMAKE_CXXFLAGS_CXX14 and QMAKE_CXXFLAGS_GNUCXX14 in your project:

     win32-g++ { QMAKE_CXXFLAGS_CXX14 = -std=c++14 QMAKE_CXXFLAGS_GNUCXX14 = -std=c++14 } 
  • Change the default values โ€‹โ€‹for these two variables as described above in mkspecs/win32-g++/qmake.conf in your Qt installation folder.

  • Add a new mkspec , copied from win32-g++ , designed for your compiler, and create your Qt using it. Then the whole project that uses Qt will correctly run wrt C ++ 14 support.

+1
source share

All Articles