1

How can I add another compiler and use it with QT?
I'm asking because I couldn't find it anywhere on the web how to do it.

2
  • which build system? which compiler? Commented Nov 1, 2011 at 10:08
  • @FrankOsterfeld windows, compiler gcc 4.6.1 Commented Nov 1, 2011 at 10:13

2 Answers 2

3

If you are using qmake, you can override the compiler used by the current mkspec with QMAKE_CXX, e.g. qmake QMAKE_CXX=g++-4.6.

To permanently override it, you'll need a new or edit the mkspec files. You can browse where they are with qmake -query and look at the QMAKE_MKSPECS variable. From there, the directory "default" is used if you do not use the -spec parameter in qmake. In that directory, the file qmake.conf will contain the mentioned QMAKE_CXX paramater that determines the compiler.

Sign up to request clarification or add additional context in comments.

5 Comments

is there a way to do it via IDE? I'm not using qmake.
Which IDE? If it's QtCreator it uses qmake internally by default, and the same rules apply. You can add the QMAKE_CXX from Projects side tab and build steps. If its not qmake, you'll need to refer to the build tool documentation about the compiler.
Assuming you have your project open in QtCreator. Click "Projects" (on the left side bar). Then click "details" on the qmake row, inside "Build Steps". You should see "Additional Arguments". Write "QMAKE_CXX=g++-4.6", or whatever compiler you want there. This of course assuming that the compiler is in the PATH and QtCreator finds it. Clean and rebuild.
am I suppose to change those XX in QMAKE_CXX or just leave it as it is. And another question connected with this: Am I suppose to somehow create this QMAKE_CXX or just type it as you've suggested? Thanks.
Tatu in "Additional Arguments" I've typed first time: QMAKE_CXX=C:\MinGW32\bin\g++, this doesn't work for me, second time: QMAKE_CXX=g++-4.6.1 - also doesn't work. My gcc 4.6.1 resides in C:\MinGW32\bin\g++ and this IS in PATH.
0

On MacOs, if you want to use gcc/g++ you can edit the Project (.pro) file to include (at the top):

QMAKE_CC  = gcc
QMAKE_CXX = g++

Then run qmake against the Project file.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.