13

I am building Qt 5.4 and I want to use my custom built GCC version which is different from the system one. I don't want to replace system GCC with my one. However, I don't see how can I alter the compiler absolute path that the Qt build system uses, as well as how to add custom flags. Usually open source libraries use CXX and CXXFLAGS variables to alter compiler absolute path and its options, but it looks like Qt build system ignores these variables.

Does Qt 5.4 build system have any options similar to common for GNU projects CXX and CXXFLAGS, as well as LD and LDFLAGS?

5
  • What OS are you on? (Linux?) Commented Feb 10, 2015 at 15:15
  • 3
    You'll probably need to create a custom qmake.conf file. See here or here. Commented Feb 10, 2015 at 15:17
  • @Cameron Yes, my OS is Linux (CentOS 6). Commented Feb 10, 2015 at 15:26
  • @BartoszKP Good idea, it looks like it is required to create own platform. I use linux-g++ platform as a base and just modified system variables related to pathes to compile QT. Commented Feb 10, 2015 at 16:03
  • @Vitaliy If it works, consider posting a self-answer :) I don't know it well enough to do that. Good luck! Commented Feb 10, 2015 at 17:21

2 Answers 2

8

As @BartoszKP adviced, it is required to make custom build platform. Easier (but less elegant and less "educational") idea is to modify existing platform. I used linux-g++ platform as a base. This platform qmake.conf file path relative to source code directory is qtbase/mkspecs/linux-g++/qmake.conf. I added following lines at the very bottom of this file:

QMAKE_CXX               = /path/to/custom/g++
QMAKE_LINK              = /path/to/custom/g++
QMAKE_LFLAGS            += -custom-link-flags-here
QMAKE_CC                = /path/to/custom/gcc
QMAKE_LINK_C            = /path/to/custom/gcc

Now Qt build platform uses my custom compiler instead of existing system one, and it adds my custom linker flags.

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

1 Comment

Thanks for the tip. I had to not only do this (in fact for me it didn't seem to actually work with the change to qmake.conf). I actually had to make the changes to mkspecs/common/g++-base.conf; this ensured that both the qmake executable and the build used the desired compiler.
0

The easiest way is to use :

make CC=/path/to/custom/gcc CXX= /path/to/custom/g++ LINK=/path/to/custom/g++ LFLAGS= -custom-link-flags-here

Now Qt will use your custom compiler instead of existing system one.

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.