編譯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
了。html
提供一個我已經編譯好的了mysql
linux下64位gcc編譯linux
http://pan.baidu.com/s/1eRMnf26 提取密碼 iz39android
windows下64位mingw編譯c++
http://pan.baidu.com/s/1qYh7yGG 提取密碼 6burweb
由於編譯的時候,安裝路徑已經硬編碼到了qmake中(使用strings qmake|grep qt_
來查看)。
因此若是改變了安裝的目錄,須要到安裝目錄下的bin
目錄下建立文件qt.conf
,其內容以下:sql
[Paths] Prefix = 安裝路徑
首先下載源碼包qt-everywhere-opensource-src-5.6.0.7z
而後解壓shell
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
中,解壓後進入這個目錄。windows
先使用./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) |
下表中第一列中的*
表示默認並可行的。+
表示默認,但須要進行評估(檢測),評估經過纔可接受。
選項 | 做用 | |
---|---|---|
* | -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*.so 爲libQt*<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) |
選項 | 做用 |
---|---|
-no-slog2 | 不編譯 slog2 的支持 |
-slog2 | 編譯 slog2 的支持 |
-no-pps | 不編譯 pps 的支持 |
-pps | 編譯 pps 的支持 |
-no-imf | 不編譯 imf 的支持 |
-imf | 編譯 imf 的支持 |
-no-lgmon | 不編譯 lgmon 的支持 |
-lgmon | 編譯 lgmon 的支持 |
選項 | 做用 | |
---|---|---|
-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許可不兼容。 |
下面是我編譯的時候使用的選項。
-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
庫。
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的時候最常遇見的。這裏列舉出我遇見的的錯誤。
錯誤提示以下
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-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
以後再去修改這個文件。
編譯完成後,使用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
http://www.cnblogs.com/oloroso/p/5407779.html