Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring the GCC compiler switches in Qt, QtCreator, and QMake

I recently tried to use Qt Creator 1.3.2, Qt 4.6.2, and GCC 4.4.0 (32-bit version) on Windows 7 (64-bit) to compile an application using some of the experimental C++0x extensions and encountered the following (fatal) error:

This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.

In my search for a solution, I came across the thread qmake and compiler flags?, and added the following to the .pro file:

CXXFLAGS += -std=c++0x 

but that didn't seem to make a difference.

So, I expect there's some tag I need to add to the .pro (project) file, but I've never messed with the GCC compiler switches in Qt, QMake, and QtCreator before, and I am uncertain about the proper invokation / incantation. So, my question is how do you set GCC compiler switches when using QtCreator, QMake, and Qt?

like image 623
andand Avatar asked Jun 07 '10 04:06

andand


People also ask

How do I add GCC to QT?

Click Tools > Options. Select Build & Run from the list at the left. In the right pane, select the Compilers tab. Click Add and select GCC > C++ from the drop-down menu to add a new C++ native compiler.

Is qmake a compiler?

qmake was created by Trolltech (now The Qt Company). It is distributed and integrated with the Qt application framework, and automates the creation of moc (meta object compiler) and rcc (resource compiler) sources, which are used in Qt's meta-object system and in the integration of binary resources (e.g., pictures).

Which compiler is used in Qt?

Qt Creator uses the C++ compiler from the GNU Compiler Collection on Linux. On Windows it can use MinGW or MSVC with the default install and can also use Microsoft Console Debugger when compiled from source code. Clang is also supported.


1 Answers

It boils down to reading the manual. Instead of using CXXFLAGS in the .pro file, you need to use QMAKE_CXXFLAGS as in:

main.cpp:

#include <cinttypes>  int main() { return 0; } 

main.pro:

SOURCES += main.cpp QMAKE_CXXFLAGS += -std=c++0x 
like image 104
andand Avatar answered Sep 23 '22 12:09

andand