How to build Qt with custom compilers and custom flags?

I am creating Qt 5.4 and I want to use my own version of GCC , which is different from the system version. I do not want to replace the GCC system with mine. However, I do not see how I can change the absolute path of the compiler that the Qt build system uses, as well as how to add custom flags. Typically, open source libraries use the CXX and CXXFLAGS to change the absolute path of the compiler and its parameters, but it looks like the Qt build system ignores these variables.

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

+8
c ++ qt
source share
2 answers

As @BartoszKP advises, you need to create a custom build platform. A simpler (but less elegant and less "educational") idea is to modify the existing platform. I used the linux-g++ platform as the base. This path to the qmake.conf file system is relative to the qtbase/mkspecs/linux-g++/qmake.conf . I added the following lines at the very end 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 the Qt build platform uses my own compiler instead of the existing system, and it adds my own linker flags.

+3
source share

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 own compiler instead of the existing system.

0
source share

All Articles