2

I am trying to compile a Qt project that uses the "override" keyword, and thus needs GCC 4.8. I have installed GCC 4.8 on my Ubuntu 12.04 machine already, and it lives in /usr/bin as gcc-4.8 and g++-4.8.

I have added a compiler in the Qt Creator with the "Compiler path" set to /usr/bin/g++-4.8, and made sure the kit I am using is set to use this compiler. However, the Makefile that qmake generates still sets CC = gcc and CXX = g++. If I manually append -4.8, it does what I want. Why is qmake not generating the Makefile to do that? What am I missing in Qt Creator such that it points to the wrong gcc binaries?

I realize that update-alternatives could do the job, but I'd like to not have to have to run that just to run an alternative version of gcc. (Maybe in the future I will want two Qt projects with different versions of gcc.)

2

Found out how to fix this: add the following to my .pro file:

linux-g++ | linux-g++-64 | linux-g++-32 {
    QMAKE_CXX = g++-4.8
    QMAKE_CC = gcc-4.8
}
  • I'm told that linux-g++* would work in place of linux-g++ | linux-g++-64 | linux-g++-32. – Aaron Campbell Jun 17 '15 at 16:47
  • Unfortunately, this is not a generic fix, but rather a workaround of the apparent limitation that qt creator did not use the proper name of the binary defined for the compiler in the kit... This problem occured in Qt Creator 3.5.1, but I have not tested it in newer releases. – Joost Sep 2 '16 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.