Changing compiler in Qt
How to change compiler (GCC) in Qt? I've installed GCC 4.4 and 4.6. At the momment Qt uses 4.4 but I'd like i开发者_运维技巧t to use 4.6. How to do it?
In the build sequence it may have a qmake
command like qmake YourProject.pro -r -spec linux-g++-64
the choice of the tool chain is done in the spec
file here linux-g++-64
. Your will find this file in path-to-the-sdk/qt/mkspecs/linux-g++-64
(you get the concept right?)... If you open the spec file you will see that it includes the linux
spec and the g++
spec.
One solution is to copy the g++
spec file and rename it g++-4.6
for example edit it and change :
QMAKE_CC = gcc
QMAKE_CXX = g++
to :
QMAKE_CC = gcc-4.6
QMAKE_CXX = g++-4.6
Idem for the linux-g++-64
it can be copied to linux-g++-4.6-64
and modify the include(...)
command to include your new g++-4.6
file.
Finally build your project with qmake YourProject.pro -r -spec linux-g++-4.6-64
.
I hope it's clear :) ...
I realise I am very late for the party but on Linux it is as simple as follows:
qmake -makefile <your-project.pro> -spec linux-clang
On my system, all sorts of different mkspecs
are available at:
/usr/lib/x86_64-linux-gnu/qt5/mkspecs
Running make CC=my-custom-gcc CXX=my-custom-g++ LINK=my-custom-g++
seems to do the trick for me. But it might not be 100% safe (i.e. I wouldn't be surprised if running qmake with Linux specs and then specifying mingw32 compilers would fail).
If you are using Qt Creator 2.2.0, you can try Tools > Options > Tool Chains
and then Add > MinGW
.
精彩评论