zoukankan      html  css  js  c++  java
  • 乌合之众:linux下编译qt5.6.0静态库(下载,使用./configure --help来看看都有哪些参数。超详细,有每一个模块的说明。如果改变了安装的目录,需要到安装目录下的bin目录下创建文件qt.conf)good

    linux下编译qt5.6.0静态库

    编译QT是一件比较麻烦的事情。所以如果没有必要,就不要编译了。如果你只需要使用QT的一些基本功能,那么就只编译源码目录下的qtbase目录下的东西即可。
    下面所介绍的都只是在linux下适用的(windows下使用MinGW也可以,QT提供的MinGW安装包是32位的,需要64位的可以参考)。
    在编译前,最好先安装完成相关的依赖包,主要是xcb/opengl等。编译器使用gcc5及以上版本速度会比较快。i5-4460 CPU @ 3.20GHz+8G内存下编译时间大概是2.5个小时。
    编译的时候对磁盘空间要求非常非常的大75G ./qt-src/qt-opensource-src-5.6.0(这是还没有完全编译完时候的情况),如果无法接受,就别编译debug版本和examples了。

    提供一个我已经编译好的了

    linux下64位gcc编译

    http://pan.baidu.com/s/1eRMnf26                 提取密码    iz39

    windows下64位mingw编译

    http://pan.baidu.com/s/1qYh7yGG                提取密码    6bur

    因为编译的时候,安装路径已经硬编码到了qmake中(使用strings qmake|grep qt_来查看)。
    所以如果改变了安装的目录,需要到安装目录下的bin目录下创建文件qt.conf,其内容如下:

    [Paths]
    Prefix = 安装路径
    

    首先下载源码包qt-everywhere-opensource-src-5.6.0.7z
    然后解压

    7z x -o/home/o/qt-src/qt-opensource-src-5.6.0 qt-everywhere-opensource-src-5.6.0.7z
    cd /home/o/qt-src/qt-opensource-src-5.6.0
    

    我这里解压到/home/o/qt-src/qt-opensource-src-5.6.0中,解压后进入这个目录。

    configure生成makefile

    使用./configure --help来看看都有哪些参数,这里就不贴命令输出结果了,直接把选项都翻译出来

    安装选项

    选项作用
    -prefix <dir> 指定部署目录(默认 /usr/local/Qt-5.6.0)
    -extprefix <dir> 安装目录(默认 SYSROOT/PREFIX)
    -hostprefix [dir] 运行在这个主机上的构建工具的安装目录,如果不给定,使用当前目录. (默认 EXTPREFIX)

    你可以用这些来改变安装的布局。请注意,所有目录除sysconfdir外,其他的应位于-prefix/ hostprefix下

    选项作用
    -bindir <dir> 用户可执行文件将安装到这个目录(默认 PREFIX/bin)
    -headerdir <dir> 头文件安装目录(默认 PREFIX/include)
    -libdir <dir> 库文件安装目录(默认 PREFIX/lib)
    -archdatadir <dir> QT相关的数据将被安装到<dir>(默认 PREFIX)
    -plugindir <dir> 插件安装目录(默认 ARCHDATADIR/plugins)
    -libexecdir <dir> 程序的可执行文件安装目录(默认 ARCHDATADIR/libexec, ARCHDATADIR/bin for MinGW)
    -importdir <dir> 导入QML1安装目录(默认 ARCHDATADIR/imports)
    -qmldir <dir> 导入QML2安装目录(默认 ARCHDATADIR/qml)
    -datadir <dir> QT独立的数据安装目录(default PREFIX)
    -docdir <dir> 文档安装目录(default DATADIR/doc)
    -translationdir <dir> Qt程序的翻译数据安装目录(default DATADIR/translations)
    -sysconfdir <dir> 设置使用QT程序的搜寻目录(default PREFIX/etc/xdg)
    -examplesdir <dir> 示例文件安装目录(default PREFIX/examples)
    -testsdir <dir> 测试文件安装目录(default PREFIX/tests)
    -hostbindir <dir> 主机可执行文件安装目录(default HOSTPREFIX/bin)
    -hostlibdir <dir> 主机库文件安装目录(default HOSTPREFIX/lib)
    -hostdatadir <dir> qmake使用数据安装目录(default HOSTPREFIX)

    Configure选项

    下表中第一列中的*表示默认并可行的。+表示默认,但需要进行评估(检测),评估通过才可接受。

     选项作用
    * -release 编译和链接Qt的release版本
      -debug 编译和链接debug版本
      -debug-and-release 编译和链接release和debug两个版本的QT.
    没有和有debug输出(仅适用于MAC)
      -force-debug-info 强制为release构建输出调试信息
      -developer-build Qt开发者编译和链接选项(包括自动测试/输出)
    * -no-optimized-tools 即使在调试版本中,也不构建优化的主机工具
      -optimized-tools 构建优化的主机工具,即使在调试版本
      -opensource 编译和链接Qt开源版本
      -commercial 编译和链接的Qt商业版
      -confirm-license 自动确认许可证(使用开源或是商业)
      -c++std <edition> 编译QT使用的C++标准 (c++98, c++11, c++14, c++1z) 默认: 最高支持版本
    * -shared 创建并使用Qt共享库.
      -static 创建并使用QT静态库
      -no-largefile 禁用大文件支持
    + -largefile 启用QT访问大于4 GB的文件功能
      -no-accessibility 不编译的可访问性支持
    禁用访问不推荐,它将破坏QStyle并且可能影响QT构建 
    这个选项启用将创建一个源不兼容版本的QT,这是不支持
    + -accessibility 编译访问支持.
      -no-sql-<driver> 完全禁用SQL <driver> .
      -qt-sql-<driver> 在 Qt SQL 模块启用SQL <driver>,默认是不启用的.
      -plugin-sql-<driver> 启用SQL <driver>作为一个插件在运行时链接 
    <driver>的可能值为: 
    [ db2 ibase mysql oci odbc psql sqlite sqlite2 tds ]
      -system-sqlite 利用操作系统SQLite
      -no-qml-debug 不构建在QML调试支持
    + -qml-debug 构建QML调试支持
      -platform target 构建的目标操作系统和编译器(默认检测主机系统)
    读readme文件获取支持的操作系统和编译器列表
      -no-sse2 编译不要使用SSE2指令
      -no-sse3 编译不要使用SSE3指令
      -no-ssse3 编译不要使用SSSE3指令
      -no-sse4.1 编译不要使用SSE4.1指令
      -no-sse4.2 编译不要使用SSE4.2指令
      -no-avx 编译不要使用AVX指令
      -no-avx2 编译不要使用AVX2指令
      -no-mips_dsp 编译不要使用MIPS DSP指令
      -no-mips_dspr2 编译不要使用MIPS DSP Rev2指令
      -qtnamespace <name> 把所有的Qt库代码放入namespace <name> {...}
      -qtlibinfix <infix> 重命名所有libQt*.solibQt*<infix>.so
      -testcocoon Instrument Qt with the TestCocoon code coverage tool.
      -gcov Instrument Qt with the GCov code coverage tool.
      -D <string> 显示的添加一个宏定义到预处理器
      -I <string> 显示的添加一个包含路径
      -L <string> 显示添加一个库路径
    + -pkg-config 使用pkg-config检测包括库路径。默认情况下,配置决定是否使用pkg-config或不具有启发式如检查环境变量。
      -no-pkg-config 禁用pkg-config支持
      -force-pkg-config 强制使用pkg-config (跳过pkg-config可用性启发式检测).
      -help, -h 显示帮助信息.

    第三方库:

     选项作用
      -qt-zlib 使用QT自带zlib库
    + -system-zlib 使用操作系统自带的zlib库。
    http://www.gzip.org/zlib
      -no-mtdev 不要编译mtdev支持 
    mtdev包含了应用程序对多点触摸协议的支持
    + -mtdev 启用mtdev的支持.
    + -no-journald 不要把日志输出到journald. 
    Journald是为Linux服务器打造的新系统日志方式
      -journald 日志输出到journald
    + -no-syslog 不要输出日志到syslog.
      -syslog 输出日志到syslog.
      -no-gif 不要编译GIF读取支持
      -no-libpng 不要编译PNG支持
      -qt-libpng 使用Qt自带的libpng
    + -system-libpng 使用操作系统自带的libpng 
    http://www.libpng.org/pub/png
      -no-libjpeg 不要编译JPEG支持.
      -qt-libjpeg 使用QT自带的libjpeg.
    + -system-libjpeg 使用系统自带的 libjpeg 
    http://www.ijg.org
      -no-freetype 不要编译Freetype2的支持.
      -qt-freetype 使用QT自带的libfreetype.
    + -system-freetype 使用系统自带的libfreetype(假如存在) (启用,如果-fontconfig选项开启). 
    http://www.freetype.org
      -no-harfbuzz 不要编译HarfBuzz-NG 支持.
    * -qt-harfbuzz 使用QT自带的HarfBuzz-NG 去进行文本构形. 仍然可以通过设置QT_HARFBUZZ 环境变量到”old”来禁用.
      -system-harfbuzz 使用系统自带的HarfBuzz-NG区进行文本构形.仍然可以通过设置QT_HARFBUZZ 环境变量到”old”来禁用 
    http://www.harfbuzz.org
      -no-openssl 不要编译OpenSSL的支持
      -openssl 启用运行时OpenSSL支持.
      -openssl-linked 启用并链接OpenSSL支持
      -no-libproxy 不要编译libproxy的支持
    + -libproxy 使用操作系统自带的libproxy.
      -qt-pcre 使用QT自带的PCRE library.
    + -system-pcre 使用操作系统自带的PCRE library
      -qt-xcb 使用QT自带的xcb-libraries. (libxcb.so将仍然使用操作系统自带的).
    + -system-xcb 使用操作吸引自带的xcb- libraries .
      -xkb-config-root 设置默认的XKB config root. 这个选项仅与-qt-xkbcommon-x11一起使用.
      -qt-xkbcommon-x11 在构建xcb中使用QT自带的xkbcommon library .
    + -system-xkbcommon-x11 在构建xcb中使用操作系统自带的 xkbcommon library.
      -no-xkbcommon-evdev 当编译libinput支持时,不使用X-less xkbcommon.
    * -xkbcommon-evdev 当编译libinput支持时,使用X-less xkbcommon.
      -no-xinput2 不要编译XInput2的支持.
    * -xinput2 编译XInput2支持.
      -no-xcb-xlib 不要编译Xcb-Xlib支持.
    * -xcb-xlib 编译 Xcb-Xlib支持.
      -no-glib 不要编译 Glib 支持.
    + -glib 编译 Glib 支持.
      -no-pulseaudio 不要编译PulseAudio 支持.
    + -pulseaudio 编译 PulseAudio 支持.
      -no-alsa 不要编译 ALSA 支持.
    + -alsa 编译 ALSA 支持.
      -no-gtkstyle 不要编译GTK theme 支持.
    + -gtkstyle 编译 GTK theme 支持.

    附加选项:

     选项作用
      -make <part> 在make时添加要构建的组件. (默认为:libs tools examples)
      -nomake <part> 在构建时排除组件
      -skip <module> 排除整个模块的建立
      -no-compile-examples 仅安装examples的源码,不要编译它.
      -no-gui 不要构建Qt GUI模块和依赖.
    + -gui 构建Qt GUI 模块和依赖.
      -no-widgets 不要构建Qt Widgets 模块和依赖.
    + -widgets 构建 Qt Widgets模块和依赖
      -R <string> 显示添加一个运行时库的路径去构建Qt libraries.
      -l <string> 显示添加一个library.
      -no-rpath 不使用库安装路径作为一个运行时库路径 
    在苹果的平台上,这意味着使用绝对安装名称(基于在libdir)动态库和框架。
    + -rpath 链接 Qt 库和可执行文件使用库安装路径作为运行时库路径。相当于-R install_libpath
      -continue 如果发生错误,尽量继续。
      -verbose, -v 打印每个步骤的配置过程的详细的信息。
      -silent 减少生成输出,这样可以更容易看到警告和错误。
      -no-nis 不要编译NIS 支持.
    * -nis 编译 NIS 支持.
      -no-cups 不要编译CUPS支持.
    * -cups 编译CUPS支持. 要求 cups/cups.h 和libcups.so.2.
      -no-iconv 不编译对 iconv(3) 的支持。
    * -iconv 编译对 iconv(3) 的支持。
      -no-evdev 不编译对 evdev 的支持。
    * -evdev 编译对 evdev 的支持。
      -no-tslib 不编译对 tslib 的支持 
    tslib是对触屏的支持
    * -tslib 编译对 tslib 的支持.
      -no-icu 不编译对 ICU libraries 的支持. 
    这是IBM发布的字符集编码转换库
    + -icu 编译对 ICU libraries 的支持.
      -no-fontconfig 不编译系统中的FontConfig支持
    + -fontconfig 编译系统中的FontConfig支持
      -no-strip 不对二进制文件和库的使用strip去除不需要的符号.
    * -strip 在安装时对二进制文件和库的使用strip去除不需要的符号
    * -no-pch 不使用预编译的头支持.
      -pch 使用预编译的头支持.
    * -no-ltcg 不使用链接时代码生成
      -ltcg 使用链接时代码生成.
      -no-dbus 不要编译Qt D-Bus 模块.
    + -dbus-linked 编译Qt D-Bus模块并链接到libdbus-1.
      -dbus-runtime 编译Qt D-Bus模块并动态加载libdbus-1.
      -reduce-relocations 减少通过额外的链接器优化库的重加载 
    (仅qt/X11 和Qt/linux嵌入式 ;实验性的;需要 GNU ld > = 2.18)
      -no-use-gold-linker 不要使用GNU gold linker进行链接.
    + -use-gold-linker 使用GNU gold linker进行链接.
      -force-asserts 强制启用Q_ASSERT,即使在release构建中.
      -sanitize [address/thread/memory/undefined] 启用指定编译器的sanitizer.
      -device <name> 跨平台编译<name>设备 (试验性)
      -device-option <key=value> 添加device mkspec的device选项 (试验性)
    * -no-separate-debug-info 不将调试信息存储在一个单独的文件
      -separate-debug-info 将调试信息到一个单独的文件
      -no-xcb 不要编译Xcb (X protocol C-language Binding) 支持.
    * -xcb 编译 Xcb 支持.
      -no-eglfs 不要编译EGLFS (EGL Full Screen/Single Surface) 支持.
    * -eglfs 编译 EGLFS 支持.
      -no-kms 不要编译KMS的后端.
    * -kms 编译 KMS的后端.
      -no-gbm 不要编译 GBM 的后端.
    * -gbm 编译 GBM的后端.
      -no-directfb 不要编译 DirectFB 支持.
    * -directfb 编译 DirectFB 支持.
      -no-linuxfb 不要编译Linux Framebuffer 支持.
    * -linuxfb 编译 Linux Framebuffer 支持.
    * -no-mirclient 不要编译 Mir client 支持.
      -mirclient 编译 Mir client 支持.
      -qpa <name> 设置默认的QPA 平台 (示例 xcb, cocoa, windows).
      -xplatform target 指定目标平台(在跨平台编译时)
      -sysroot <dir> <dir>设置为目标编译器和 qmake 的 sysroot 并且也设置 pkg-confing路径.
      -no-gcc-sysroot 当使用-sysroot时, 它禁用将–sysroot传递到编译器
      -no-feature-<feature> <feature>中的不编译.
      -feature-<feature> 编译<feature>中的. 
    可用的功能介绍在src/corelib/global/qfeatures.txt
      -qconfig local 使用src/corelib/global/qconfig-local.h ,而不是默认的(全部).
      -qreal [double/float] 为qreal指定类型.默认值是double。请注意,更改此标志影响二进制兼容性。
      -no-opengl 禁用OpenGL支持.
      -opengl <api> 启用 OpenGL 支持.
    不带参数时,这将会尝试自动检测的 OpenGL ES 2.0 和更高版本,或常规的桌面版OpenGL. 
    使用 es2 的<api>将替代自动检测
      -no-libinput 禁用libinput支持.
    * -libinput 启用libinput 支持.
      -no-gstreamer 禁用GStreamer支持.
    + -gstreamer <version> 启用 GStreamer 支持。
    不带参数,这将会尝试自动检测 GStreamer 0.10 和 1.0。GStreamer 1.0 是默认使用的可用时。使用 0.10 或 1.0 <version>来覆盖自动检测。
    * -no-system-proxies 默认情况下,不使用系统网络代理
      -system-proxies 默认情况下,使用系统网络代理
      -no-warnings-are-errors Make 时把warnings当做正常
      -warnings-are-errors Make时把warnings 当做错误 (如果启用了-developer-build)

    QNX/Blackberry 选项:

    选项作用
    -no-slog2 不编译 slog2 的支持
    -slog2 编译 slog2 的支持
    -no-pps 不编译 pps 的支持
    -pps 编译 pps 的支持
    -no-imf 不编译 imf 的支持
    -imf 编译 imf 的支持
    -no-lgmon 不编译 lgmon 的支持
    -lgmon 编译 lgmon 的支持

    Android 选项:

     选项作用
      -android-sdk path Android SDK 根目录 
     (默认 $ANDROID_SDK_ROOT)
      -android-ndk path Android NDK 根目录. 
     (默认 $ANDROID_NDK_ROOT)
      -android-ndk-platform 设置android 平台版本 
     (默认 android-9)
      -android-ndk-host 设置android NDK 主机类型 (linux-x86, linux-x86_64, etc.) 
     (默认 $ANDROID_NDK_HOST)
      -android-arch 设置android 体系结构 (armeabi, armeabi-v7a, x86, mips, arm64-v8a, x86_64, mips64) 
     (默认 armeabi-v7a)
      -android-toolchain-version 设置android 工具链版本 
     (默认 4.9)
      -no-android-style-assets 不编译 通过运行时设备自动提取style-assets的代码. 
    设置这将使Android风格的行为不当,但与lgpl2.1许可兼容
    * -android-style-assets 编译 通过运行时设备自动提取style-assets的代码.
    此选项将使Android平台的lgpl2.1许可不兼容。

    生成makefile

    下面是我编译的时候使用的选项。
    -platform这一个选项是用于指定目标平台的,可以看qt源码目录/qtbase/mkspecs/下的的目录,就是QT支持的平台。可以进这个目录修改qmake.conf文件来指定编译器和编译选项。
    如果同同时指定了-release-debug使用的是后者。需要同时编译两个版本的时候应该使用-debug-and-release.例如下面的输出。
    因为很多模块我也不需要,就用过-skip <module>来跳过。模块的名字就是qt-opensource-src-5.6.0下目录的名字(不要-skip qtbase).

    /home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0 [o@o-pc] [12:09]
    >./configure -prefix /home/o/pragram/qt_5.6.0_gcc5.2.1 -debug-and-release -confirm-license -opensource -c++std c++11 -static -qt-sql-mysql -qt-sql-sqlite -no-qml-debug -platform linux-g++-64  -qt-zlib -no-journald -qt-libpng -qt-libjpeg -openssl -opengl -qt-xcb -skip qtquickcontrols -skip qtquickcontrols2 -skip qtsensors -skip qtdoc
    

    下面是询问是否查看开源协议或者直接接受的。直接yes通过就好。也可以通过-confirm-license选项来自动确认

    Type '3' to view the GNU Lesser General Public License version 3.
    Type 'L' to view the Lesser GNU General Public License version 2.1.
    Type 'yes' to accept this license offer.
    Type 'no' to decline this license offer.
    
    Do you accept the terms of either license? yes
    ... ...
    

    遇到链接检查失败的情况

    这里给出一个示例,就是xcb库检查失败。

    
    Running configuration tests (phase 1)...
    Done running configuration tests.
    Creating qmake...
    .Done.
    Running configuration tests (phase 2)...
    The test for linking against libxcb and support libraries failed!
     You might need to install dependency packages, or pass -qt-xcb.
     See src/plugins/platforms/xcb/README.
    

    这个很好解决,安装下libxcb-***-dev就是了。其他的库检查失败也是一样的。也可以通过-qt-xcb选项,使用Qt自带的xcb库。

    生成makefile后进行编译

    configure成功后会出现如下提示,后面说让你使用make进行编译,make install进行安装。
    有一个警告Using static linking will disable the WebKit module.意思是 使用静态链接将禁用WebKit模块。
    最后面还有一个警告是WARNING: Using static linking will disable the use of dynamically loaded plugins. Make sure to import all needed static plugins, or compile needed modules into the library.
    意思是警告:使用静态链接将禁用动态加载插件的使用。确保导入所有需要的静态插件,或者编译所需的模块到库中。这不是一个好的做法。

    Done running configuration tests.
    
       Configure summary
    
    Build type:    linux-g++-64 (x86_64, CPU features: mmx sse sse2)
    
    Build options:
      Configuration .......... accessibility accessibility-atspi-bridge alsa audio-backend avx avx2 c++11 clock-gettime clock-monotonic compile_examples concurrent dbus dbus-linked egl eglfs egl_x11 enable_new_dtags evdev eventfd fontconfig full-config getaddrinfo getifaddrs gif glib gstreamer-0.10 harfbuzz iconv icu inotify ipv6ifname jpeg kms large-config largefile libudev linuxfb medium-config minimal-config mremap nis no-qml-debug opengl openssl png posix_fallocate precompile_header pulseaudio qpa qpa reduce_exports reduce_relocations release rpath small-config sse2 sse3 sse4_1 sse4_2 ssse3 static system-freetype threadsafe-cloexec use_gold_linker xcb xcb-plugin xcb-qt xcb-sm xcb-xlib xinput2 xkbcommon-evdev xkbcommon-qt xlib xrender zlib 
      Build parts ............ libs tools examples
      Mode ................... release
      Using sanitizer(s)...... none
      Using C++ standard ..... c++11
      Using gold linker....... yes
      Using new DTAGS ........ yes
      Using PCH .............. yes
      Using LTCG ............. no
      Target compiler supports:
        SSE2/SSE3/SSSE3 ...... yes/yes/yes
        SSE4.1/SSE4.2 ........ yes/yes
        AVX/AVX2 ............. yes/yes
    
    Qt modules and options:
      Qt D-Bus ............... yes (linked to dbus-1)
      Qt Concurrent .......... yes
      Qt GUI ................. yes
      Qt Widgets ............. yes
      Large File ............. yes
      QML debugging .......... no
      Use system proxies ..... no
    
    Support enabled for:
      Accessibility .......... yes
      ALSA ................... yes
      CUPS ................... no
      Evdev .................. yes
      FontConfig ............. yes
      FreeType ............... yes (system library)
      Glib ................... yes
      GStreamer .............. yes (0.10)
      GTK theme .............. no
      HarfBuzz ............... yes (bundled copy)
      Iconv .................. yes
      ICU .................... yes
      Image formats: 
        GIF .................. yes (in QtGui, using bundled copy)
        JPEG ................. yes (in QtGui, using bundled copy)
        PNG .................. yes (in QtGui, using bundled copy)
      libinput................ no
      Logging backends: 
        journald ............... no
        syslog   ............... no
      mtdev .................. no
      Networking: 
        getaddrinfo .......... yes
        getifaddrs ........... yes
        IPv6 ifname .......... yes
        libproxy.............. no
        OpenSSL .............. yes (loading libraries at run-time)
      NIS .................... yes
      OpenGL / OpenVG: 
        EGL .................. yes
        OpenGL ............... desktop
        OpenVG ............... no
      PCRE ................... system
      pkg-config ............. yes 
      PulseAudio ............. yes
      QPA backends: 
        DirectFB ............. no
        EGLFS ................ yes
          EGLFS i.MX6 ........ no
          EGLFS i.MX6 Wayland. no
          EGLFS EGLDevice .... no
          EGLFS GBM .......... no
          EGLFS Mali ......... no
          EGLFS Raspberry Pi . no
          EGLFS X11 .......... yes
        LinuxFB .............. yes
        Mir client............ no
        XCB .................. yes (bundled copy)
          EGL on X ........... yes
          GLX ................ no
          MIT-SHM ............ yes
          Xcb-Xlib ........... yes
          Xcursor ............ yes (loaded at runtime)
          Xfixes ............. yes (loaded at runtime)
          Xi ................. no
          Xi2 ................ yes
          Xinerama ........... yes (loaded at runtime)
          Xrandr ............. yes (loaded at runtime)
          Xrender ............ yes
          XKB ................ yes
          XShape ............. yes
          XSync .............. yes
          XVideo ............. yes
      Session management ..... yes
      SQL drivers: 
        DB2 .................. no
        InterBase ............ no
        MySQL ................ qt
        OCI .................. no
        ODBC ................. yes (plugin)
        PostgreSQL ........... yes (plugin)
        SQLite 2 ............. no
        SQLite ............... qt-qt
        TDS .................. no
      tslib .................. no
      udev ................... yes
      xkbcommon-x11........... yes (bundled copy, XKB config root: /usr/share/X11/xkb)
      xkbcommon-evdev......... yes
      zlib ................... yes (bundled copy)
    
    
    WARNING: Using static linking will disable the use of dynamically
    loaded plugins. Make sure to import all needed static plugins,
    or compile needed modules into the library.
    Info: creating super cache file /home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/.qmake.super
    
    Qt is now configured for building. Just run 'make'.
    Once everything is built, you must run 'make install'.
    Qt will be installed into /home/o/pragram/qt_5.6.0_gcc5.2.1
    
    Prior to reconfiguration, make sure you remove any leftovers from
    the previous build.
    

    编译时的错误

    编译的过程中会出现各种各样的错误,导致不能编译通过,这是最编译QT的时候最常碰见的。这里列举出我碰见的的错误。

    多重定义’QT_MODBUS()’和’QT_MODBUS_LOW()’

    错误提示如下

    g++ -m64 -fuse-ld=gold -Wl,--enable-new-dtags -o adueditor .obj/main.o .obj/mainwindow.o .obj/modbustcpclient.o .obj/adueditor_plugin_import.o .obj/moc_mainwindow.o .obj/moc_plaintextedit.o .obj/moc_modbustcpclient.o   -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/lib -lQt5Widgets -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtserialbus/lib -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtserialport/lib -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/plugins/platforms -lqxcb -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/plugins/xcbglintegrations -lqxcb-egl-integration -lqxcb-glx-integration -lxcb-glx -lQt5XcbQpa -lXi -lxcb-render-util -lSM -lICE -lxcb-render -lxcb-image -lxcb-icccm -lxcb-sync -lxcb-xfixes -lxcb-shm -lxcb-randr -lxcb-shape -lxcb-keysyms -lxcb-xinerama -lxcb-xkb -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtimageformats/plugins/imageformats -lqdds -lqicns -lqjp2 -ljasper -lqtga -lqtiff -ltiff -lqwbmp -lqwebp -lwebp -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/plugins/imageformats -lqico -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/plugins/egldeviceintegrations -lqeglfs-x11-integration -lX11-xcb -lxcb -lQt5EglDeviceIntegration -lQt5PlatformSupport -lfontconfig -lfreetype -lXrender -lXext -lX11 -lQt5Gui -lqtharfbuzzng -lEGL -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtserialbus/plugins/canbus -lqtpeakcanbus -lqtsocketcanbus -lqttinycanbus -lQt5SerialBus -lQt5SerialPort -ludev -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/plugins/bearer -lqconnmanbearer -lqgenericbearer -lqnmbearer -lQt5Network -lQt5DBus -ldbus-1 -lQt5Core -licui18n -licuuc -licudata -lpcre16 -lm -ldl -lgthread-2.0 -pthread -lglib-2.0 -lrt -lGL -lpthread 
    /usr/bin/ld.gold: error: /home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtserialbus/lib/libQt5SerialBus.a(qmodbusdevice.o): multiple definition of 'QT_MODBUS()'
    /usr/bin/ld.gold: .obj/mainwindow.o: previous definition here
    /usr/bin/ld.gold: error: /home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtserialbus/lib/libQt5SerialBus.a(qmodbusdevice.o): multiple definition of 'QT_MODBUS_LOW()'
    /usr/bin/ld.gold: .obj/mainwindow.o: previous definition here
    collect2: error: ld returned 1 exit status
    Makefile:91: recipe for target 'adueditor' failed
    make: *** [adueditor] Error 1
    

    解决的办法很简单,把下面几行注释掉即可。

    /home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtserialbus/examples/serialbus/modbus/adueditor [o@o-pc] [13:07]
    > grep QT_MODBUS *
    mainwindow.cpp:Q_LOGGING_CATEGORY(QT_MODBUS, "qt.modbus")
    mainwindow.cpp:Q_LOGGING_CATEGORY(QT_MODBUS_LOW, "qt.modbus.lowlevel")
    modbustcpclient_p.h:            qCDebug(QT_MODBUS_LOW) << "Sent TCP ADU:" << buffer.toHex();
    

    这个错误的来源在于qt-everywhere-opensource-src-5.6.0/qtserialbus/lib/libQt5SerialBus.a(qmodbusdevice.o)这个文件中对’QT_MODBUS()’和’QT_MODBUS_LOW()’有多重定义,所以解决问题还得回到这里。
    打开qt-everywhere-opensource-src-5.6.0/qtserialbus/src/serialbus目录下的amodbusdevice.cpp文件,可以看到最后两行定义了’QT_MODBUS()’和’QT_MODBUS_LOW()’,并且是在QT_BEGIN_NAMESPACE下。而这里在mainwindow.cpp文件中也定义了一次,所以导致了重定义,这里注释掉即可。注释后重新编译即没有问题。

    qt_static_plugin_AssimpParserPlugin未定义

    这个问题在qt-everywhere-opensource-src-5.6.0/qt3d/examples/qt3d/目录下的qml工程都存在这个问题。这个问题的原因就是没有AssimpParserPlugin这个插件,我找到了这个插件,在qt-everywhere-opensource-src-5.6.0/qt3d/plugin目录下。
    问题来源如下

    /home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qt3d/examples/qt3d/playground-qml [o@o-pc] [14:56]
    > make
    g++ -m64 -fuse-ld=gold -Wl,--enable-new-dtags -o playground-qml .obj/window.o .obj/main.o .obj/playground-qml_qml_plugin_import.o .obj/playground-qml_plugin_import.o .obj/qrc_playground-qml.o .obj/qrc_gltf.o .obj/moc_window.o   -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qt3d/lib -lQt53DInput -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/lib -lQt53DQuick -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtdeclarative/lib -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qt3d/plugins/sceneparsers -lassimpsceneparser -lgltfsceneparser -lQt53DRender -lQt53DCore -lQt5OpenGLExtensions -lQt5Concurrent -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/plugins/platforms -lqxcb -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/plugins/xcbglintegrations -lqxcb-egl-integration -lqxcb-glx-integration -lxcb-glx -lQt5XcbQpa -lXi -lxcb-render-util -lSM -lICE -lxcb-render -lxcb-image -lxcb-icccm -lxcb-sync -lxcb-xfixes -lxcb-shm -lxcb-randr -lxcb-shape -lxcb-keysyms -lxcb-xinerama -lxcb-xkb -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtimageformats/plugins/imageformats -lqdds -lqicns -lqjp2 -ljasper -lqtga -lqtiff -ltiff -lqwbmp -lqwebp -lwebp -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/plugins/imageformats -lqico -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/plugins/egldeviceintegrations -lqeglfs-x11-integration -lX11-xcb -lxcb -lQt5EglDeviceIntegration -lQt5PlatformSupport -lfontconfig -lfreetype -lXrender -lXext -lX11 -ludev -lEGL -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtdeclarative/plugins/qmltooling -lqmldbg_debugger -lqmldbg_inspector -lQt5Quick -lqmldbg_local -lqmldbg_native -lQt5Gui -lqtharfbuzzng -lqmldbg_profiler -lqmldbg_server -lqmldbg_tcp -lQt5Qml -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/plugins/bearer -lqconnmanbearer -lqgenericbearer -lqnmbearer -lQt5Network -lQt5DBus -ldbus-1 -lQt5Core -licui18n -licuuc -licudata -lpcre16 -lm -ldl -lgthread-2.0 -pthread -lglib-2.0 -lrt -lGL -lpthread 
    playground-qml_plugin_import.cpp:4: error: undefined reference to 'qt_static_plugin_AssimpParserPlugin()'
    collect2: error: ld returned 1 exit status
    Makefile:105: recipe for target 'playground-qml' failed
    make: *** [playground-qml] Error 1
    

    这个错误出现的原因在于playground-qml_plugin_import.cpp文件中使用了Q_IMPORT_PLUGIN(AssimpParserPlugin)来引入静态插件AssimpParserPlugin的。如果是动态插件,是不需要这么引入的。静态插件将编译到目标程序中去。
    没有这个插件,那么就先把它注释掉,再编译就可以了。
    因为playground-qml_plugin_import.cpp是Qt的qml工具生成的,所以需要在qmake之后再去修改这个文件。

    在Qt Creator中使用编译出的QT库

    编译完成后,使用make install进行安装。如果你没有指定安装的目录,可能需要root权限。

    可以先去安装目录中的目录结构

    /home/o/pragram/qt_5.6.0_gcc5.2.1 [o@o-pc] [1:49]
    > ls
    bin  doc  examples  include  lib  mkspecs  phrasebooks  plugins  qml  translations
    
    /home/o/pragram/qt_5.6.0_gcc5.2.1 [o@o-pc] [1:49]
    > ls bin 
    assistant   fixqt4headers.pl  lrelease  pixeltool             qdbuscpp2xml  qdoc            qhelpgenerator  qml               qmllint      qmltestrunner  qtplugininfo      syncqt.pl    xmlpatternsvalidator
    canbusutil  lconvert          lupdate   qcollectiongenerator  qdbusviewer   qgltf           qlalr           qmleasing         qmlmin       qtdiag         qtwaylandscanner  uic
    designer    linguist          moc       qdbus                 qdbusxml2cpp  qhelpconverter  qmake           qmlimportscanner  qmlprofiler  qtpaths        rcc               xmlpatterns
    
    /home/o/pragram/qt_5.6.0_gcc5.2.1 [o@o-pc] [1:49]
    > ls lib 
    cmake                   libQt53DQuick.la         libQt5Core.la                   libQt5Location.la            libQt5OpenGL.la            libQt5QuickParticles.prl  libQt5Sql.la             libQt5Widgets.la
    libEnginio.a            libQt53DQuick.prl        libQt5Core.prl                  libQt5Location.prl           libQt5OpenGL.prl           libQt5Quick.prl           libQt5Sql.prl            libQt5Widgets.prl
    libEnginio.la           libQt53DQuickRender.a    libQt5DBus.a                    libQt5Multimedia.a           libQt5PlatformSupport.a    libQt5QuickTest.a         libQt5Svg.a              libQt5X11Extras.a
    libEnginio.prl          libQt53DQuickRender.la   libQt5DBus.la                   libQt5Multimedia.la          libQt5PlatformSupport.la   libQt5QuickTest.la        libQt5Svg.la             libQt5X11Extras.la
    libpoly2tri.a           libQt53DQuickRender.prl  libQt5DBus.prl                  libQt5Multimedia.prl         libQt5PlatformSupport.prl  libQt5QuickTest.prl       libQt5Svg.prl            libQt5X11Extras.prl
    libpoly2tri.prl         libQt53DRender.a         libQt5Designer.a                libQt5MultimediaQuick_p.a    libQt5Positioning.a        libQt5QuickWidgets.a      libQt5Test.a             libQt5XcbQpa.a
    libqgsttools_p.a        libQt53DRender.la        libQt5DesignerComponents.a      libQt5MultimediaQuick_p.la   libQt5Positioning.la       libQt5QuickWidgets.la     libQt5Test.la            libQt5XcbQpa.la
    libqgsttools_p.prl      libQt53DRender.prl       libQt5DesignerComponents.la     libQt5MultimediaQuick_p.prl  libQt5Positioning.prl      libQt5QuickWidgets.prl    libQt5Test.prl           libQt5XcbQpa.prl
    libQt53DCore.a          libQt5Bluetooth.a        libQt5DesignerComponents.prl    libQt5MultimediaWidgets.a    libQt5PrintSupport.a       libQt5Script.a            libQt5UiTools.a          libQt5Xml.a
    libQt53DCore.la         libQt5Bluetooth.la       libQt5Designer.la               libQt5MultimediaWidgets.la   libQt5PrintSupport.la      libQt5Script.la           libQt5UiTools.la         libQt5Xml.la
    libQt53DCore.prl        libQt5Bluetooth.prl      libQt5Designer.prl              libQt5MultimediaWidgets.prl  libQt5PrintSupport.prl     libQt5Script.prl          libQt5UiTools.prl        libQt5XmlPatterns.a
    libQt53DInput.a         libQt5Bootstrap.a        libQt5EglDeviceIntegration.a    libQt5Network.a              libQt5Qml.a                libQt5ScriptTools.a       libQt5WaylandClient.a    libQt5XmlPatterns.la
    libQt53DInput.la        libQt5Bootstrap.la       libQt5EglDeviceIntegration.la   libQt5Network.la             libQt5QmlDevTools.a        libQt5ScriptTools.la      libQt5WaylandClient.la   libQt5XmlPatterns.prl
    libQt53DInput.prl       libQt5Bootstrap.prl      libQt5EglDeviceIntegration.prl  libQt5Network.prl            libQt5QmlDevTools.la       libQt5ScriptTools.prl     libQt5WaylandClient.prl  libQt5Xml.prl
    libQt53DLogic.a         libQt5CLucene.a          libQt5Gui.a                     libQt5Nfc.a                  libQt5QmlDevTools.prl      libQt5SerialBus.a         libQt5WebChannel.a       libqtharfbuzzng.a
    libQt53DLogic.la        libQt5CLucene.la         libQt5Gui.la                    libQt5Nfc.la                 libQt5Qml.la               libQt5SerialBus.la        libQt5WebChannel.la      libqtharfbuzzng.prl
    libQt53DLogic.prl       libQt5CLucene.prl        libQt5Gui.prl                   libQt5Nfc.prl                libQt5Qml.prl              libQt5SerialBus.prl       libQt5WebChannel.prl     libxcb-static.a
    libQt53DQuick.a         libQt5Concurrent.a       libQt5Help.a                    libQt5OpenGL.a               libQt5Quick.a              libQt5SerialPort.a        libQt5WebSockets.a       libxcb-static.prl
    libQt53DQuickInput.a    libQt5Concurrent.la      libQt5Help.la                   libQt5OpenGLExtensions.a     libQt5Quick.la             libQt5SerialPort.la       libQt5WebSockets.la      pkgconfig
    libQt53DQuickInput.la   libQt5Concurrent.prl     libQt5Help.prl                  libQt5OpenGLExtensions.la    libQt5QuickParticles.a     libQt5SerialPort.prl      libQt5WebSockets.prl
    libQt53DQuickInput.prl  libQt5Core.a             libQt5Location.a                libQt5OpenGLExtensions.prl   libQt5QuickParticles.la    libQt5Sql.a               libQt5Widgets.a
    

    具体过程如图

    添加一个版本的QT 
      
      

    http://www.cnblogs.com/oloroso/p/5407779.html

  • 相关阅读:
    Uploader 文件上传
    filters过滤器的使用
    Calendar中遇到的问题
    中科院之旅
    Python基础教程:列表推导式详解
    不会也要知道的,Python四种实现排序的方法
    2021字节跳动校招秋招算法面试真题解题报告--leetcode19 删除链表的倒数第 n 个结点,内含7种语言答案
    2021字节跳动校招秋招算法面试真题解题报告--leetcode206 反转链表,内含7种语言答案
    求协方差
    国外卡组织的 交换费-interchangefee(发卡行服务费) 和 银联对比
  • 原文地址:https://www.cnblogs.com/findumars/p/5422100.html
Copyright © 2011-2022 走看看