Qt5.7.0配置选项(configure options)
Qt5.7.0配置选项(configure options)
configure是一个命令行工具,用于配置Qt编译到指定平台。configure必须运行于Qt源码根目录。当运行configure时,编译源码使用的是所选工具链中的make工具。
一.源码目录、编译目录和安装目录
源码目录就是包含源码的目录。编译目录是包含Makefiles文件、object文件和其他中间文件的目录。安装目录是二进制文件和库文件安装的目录。
当编译目录和源码目录不一样时,称为影子编译(shadow build),比如说,Qt Creator默认是使用影子编译来编译工程的。这里也可以使用影子编译,方法就是新建一个目录,然后cd到该目录中运行configure,如下所示。
mkdir ~/qt-buildcd ~/qt-build~/qt-source/configure
此时,configure时生成的Makefiles文件,以及编译时生成的中间文件都会拷贝到qt-build目录。不仅如此,通过影子编译,可以同时进行多个不同配置选项的编译过程,互不影响。
默认的安装目录和平台相关,但是在configure时,可以通过-prefix选项指定安装目录,比如./configure -prefix /opt/Qt-5.7。这样一来,在执行make install指令时,编译完成的bin、lib或者其他子目录就会拷贝到/opt/Qt-5.7目录中。
二.包含和排除Qt模块
通过configure,可以包含或排除指定的Qt模块。需要注意的是,许多模块依赖于其他的模块,不恰当的配置选项会导致依赖问题。
1.排除Qt模块
使用configure的-skip选项可以排除Qt模块,一般情况下模块名就是源码目录中对应的子目录名。有些子目录会包含多个模块,比如说qtconnectivity目录就包含了Qt NFC模块和Qt Bluetooth模块,排除这两个模块需要将-skip qtconnectivity作为配置参数,如下所示。
./configure -skip qtconnectivity
2.包含或排除特性
-feature-
./configure -no-feature-accessibility
三.第三方库
Qt源码中包含了一些第三方库,如果想使用Qt自带的第三方库,可用通过-qt配置;如果想使用系统中的第三方库,可用通过-system配置。下表中列出一些第三方库及其配置选项。
Library Name | Bundled in Qt | Installed in System |
zlib | | |
libjpeg | | |
libpng | | |
xcb | | |
xkbcommon | | |
freetype | | |
PCRE | | |
HarfBuzz-NG | | |
当然,也可以禁用这些第三方库,用-no替换-qt就行,如下所示。
./configure -no-zlib -qt-libjpeg -qt-libpng -system-xcb
四.编译选项
-platform选项指定了目标平台和编译时使用的编译器,Qt支持的平台和编译器都在qtbase/mkspecs目录中。比如,在Ubuntu Linux系统中,Qt能被多种编译器编译,比如clang和g++,如下所示。
./configure -platform linux-clang./configure -platform linux-g++./configure -platform linux-g++-32
对于Windows系统,可以用MinGW或者Visual Studio工具链,如下所示。
configure.bat -platform win32-g++configure.bat -platform win32-msvc2010
五.交叉编译选项
通用的选项如下所示。
-xplatform:指定目标平台,可用的xplatform与platform类似,也在qtbase/mkspecs目录中。
-device:指定特殊的设备或芯片,configure兼容的device在qtbase/mkspecs/devices目录中。
-device-option:设置额外的qmake参数,比如,-device-option CROSS_COMPILE=
在Windows中,Qt可以配置使用系统的OpenGL或者自带的ANGLE。默认情况下,Qt会配置使用ANGLE,ANGLE依赖于DirectX SDK。ANGLE使得依赖于OpenGL的Qt应用程序可以在没有安装OpenGL的机器上运行。
-opengl选项可以配置Qt使用目标机器上的OpenGL,如下所示。
configure.bat -opengl desktop
desktop选项告知Qt使用Windows上的OpenGL,当然前提是要求Windows上的OpenGL与Qt兼容。
-opengl选项支持两个版本的OpenGL ES,一个是es2,一个是es1,如下所示。
configure.bat -opengl es2
七.configure -h
configure -h与configure -help功能相同,显示所有配置选项。以下是Windows上Qt5.7.0的配置选项。
Installation options:These are optional, but you may specify install directories. -prefix
Third Party Libraries: -qt-zlib ........... Use the zlib bundled with Qt. + -system-zlib ....... Use zlib from the operating system.See -qt-pcre ........... Use the PCRE library bundled with Qt. + -system-pcre ....... Use the PCRE library from the operating system.See -icu ............... Use the ICU library. * -no-icu ............ Do not use the ICU library.See -no-gif ............ Do not compile GIF reading support. -no-libpng ......... Do not compile PNG support. -qt-libpng ......... Use the libpng bundled with Qt. + -system-libpng ..... Use libpng from the operating system.See -no-libjpeg ........ Do not compile JPEG support. -qt-libjpeg ........ Use the libjpeg bundled with Qt. + -system-libjpeg .... Use libjpeg from the operating system.See -no-doubleconversion Use sscanf_l and snprintf_l for (imprecise) double con version. -qt-doubleconversion Use the libdouble-conversion bundled with Qt. -system-doubleconversion Use the libdouble-conversion provided by the system. -no-freetype ....... Do not compile in Freetype2 support. * -qt-freetype ....... Use the libfreetype bundled with Qt. -system-freetype ... Use the libfreetype provided by the system. -fontconfig ........ Build with FontConfig support. * -no-fontconfig ..... Do not build with FontConfig support. -no-harfbuzz ....... Do not compile in HarfBuzz-NG support. * -qt-harfbuzz ....... Use HarfBuzz-NG bundled with Qt to do text shaping.It can still be disabled by settingthe QT_HARFBUZZ environment variable to "old". -system-harfbuzz ... Use HarfBuzz-NG from the operating system to do text shaping. It can still be disabled by setting the QT_HARFBUZZ environment variable to"old".See + -angle ............. Use the ANGLE implementation of OpenGL ES 2.0. -no-angle .......... Do not use ANGLE.See Qt for Windows only: -no-incredibuild-xge Do not add IncrediBuild XGE distribution commands to custom build steps. + -incredibuild-xge .. Add IncrediBuild XGE distribution commands to custom build steps. This will distribute MOC and UIC steps,and other custom buildsteps which are added to theINCREDIBUILD_XGE variable.(The IncrediBuild distribution commands are only addedto Visual Studio projects) * -no-plugin-manifests Do not embed manifests in plugins. -plugin-manifests .. Embed manifests in plugins. -no-qmake .......... Do not compile qmake. * -qmake ............. Compile qmake. -qreal [double|float] typedef qreal to the specified type. The default is double.Note that changing this flag affects binary compatibility. -no-rtti ........... Do not compile runtime type information. * -rtti .............. Compile runtime type information. -no-strip .......... Do not strip libraries and executables of debug info when installing. * -strip ............. Strip libraries and executables of debug info when installing. -no-sse2 ........... Do not compile with use of SSE2 instructions. + -sse2 .............. Compile with use of SSE2 instructions. -no-sse3 ........... Do not compile with use of SSE3 instructions. + -sse3 .............. Compile with use of SSE3 instructions. -no-ssse3 .......... Do not compile with use of SSSE3 instructions. + -ssse3 ............. Compile with use of SSSE3 instructions. -no-sse4.1 ......... Do not compile with use of SSE4.1 instructions. + -sse4.1 ............ Compile with use of SSE4.1 instructions. -no-sse4.2 ......... Do not compile with use of SSE4.2 instructions. + -sse4.2 ............ Compile with use of SSE4.2 instructions. -no-avx ............ Do not compile with use of AVX instructions. + -avx ............... Compile with use of AVX instructions. -no-avx2 ........... Do not compile with use of AVX2 instructions. + -avx2 .............. Compile with use of AVX2 instructions. -no-avx512 ......... Do not compile with use of AVX512 instructions. + -avx512 ............ Compile with use of AVX512 instructions. -no-ssl ............ Do not compile support for SSL. + -ssl ............... Enable run-time SSL support. -no-openssl ........ Do not compile support for OpenSSL. + -openssl ........... Enable run-time OpenSSL support. -openssl-linked .... Enable linked OpenSSL support. -no-libproxy ....... Do not compile in libproxy support. + -libproxy .......... Compile in libproxy support (for cross compilation targets). -no-dbus ........... Do not compile in D-Bus support. -dbus-linked ....... Compile in D-Bus support and link to libdbus-1. -dbus-runtime ...... Compile in D-Bus support and load libdbus-1 dynamically. -no-audio-backend .. Do not compile in the platform audio backend into Qt Multimedia. + -audio-backend ..... Compile in the platform audio backend into Qt Qt Multimedia. * -no-wmf-backend .... Do not compile in the windows media foundation backend into Qt Multimedia. -wmf-backend ....... Compile in the windows media foundation backend into Qt Multimedia. -no-qml-debug ...... Do not build the in-process QML debugging support. * -qml-debug ......... Build the in-process QML debugging support. -no-directwrite .... Do not build support for DirectWrite font rendering. + -directwrite ....... Build support for DirectWrite font rendering. * -no-direct2d ....... Do not build the Direct2D platform plugin. -direct2d .......... Build the Direct2D platform plugin (experimental,requires Direct2D availability on target systems, e.g. Windows 7 with Platform Update, Windows 8, etc.) -no-style-