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.
我正在构建qt5.4,我想使用我定制的GCC版本,它与系统版本不同。我不想用我的GCC取代系统GCC。但是,我不知道如何更改Qt构建系统使用的编译器绝对路径,以及如何添加自定义标志。通常开源库使用CXX和CXXFLAGS变量来改变编译器绝对路径及其选项,但是Qt构建系统似乎忽略了这些变量。
Does Qt 5.4 build system have any options similar to common for GNU projects CXX
and CXXFLAGS
, as well as LD
and LDFLAGS
?
Qt 5.4构建系统是否有与GNU项目CXX和CXXFLAGS、LD和LDFLAGS类似的选项?
2 个解决方案
#1
4
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:
正如@BartoszKP的建议,需要定制构建平台。更简单(但不那么优雅和“教育”)的想法是修改现有的平台。我使用linux-g+平台作为基础。这个平台qmake。与源代码目录相关的conf文件路径是qtbase/mkspec /linux-g+ /qmake.conf。我在这个文件的最下面添加了以下几行:
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.
现在Qt构建平台使用我的自定义编译器而不是现有的系统编译器,它添加了我的自定义链接器标志。
#2
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.
现在,Qt将使用您的自定义编译器,而不是现有的系统。
#1
4
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:
正如@BartoszKP的建议,需要定制构建平台。更简单(但不那么优雅和“教育”)的想法是修改现有的平台。我使用linux-g+平台作为基础。这个平台qmake。与源代码目录相关的conf文件路径是qtbase/mkspec /linux-g+ /qmake.conf。我在这个文件的最下面添加了以下几行:
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.
现在Qt构建平台使用我的自定义编译器而不是现有的系统编译器,它添加了我的自定义链接器标志。
#2
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.
现在,Qt将使用您的自定义编译器,而不是现有的系统。