Qt configure 参数不完全说明
生活随笔
收集整理的這篇文章主要介紹了
Qt configure 参数不完全说明
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
只需要加個 -fast參數就ok了。其他參數視自己情況而定,比如你不需要qt3支持可以添加-no-qt3support,或者不需要webkit插件 -no-webkit配置參數選項:
前面是*號的表示默認參數. +號表示該功能要求被評估,評估成功后才能被接受.
? ?-release ........... 調試關閉.沒有調試庫,自己的項目只能發布,不能調試(沒有調試庫的緣故),如果你硬要編譯debug版本的話,會提示找不到xxxxxd.dll
* -debug ............. 只有調試庫,沒有釋放庫,也就是說以后自己的項目只能調試,如果你硬要編譯debug版本的話,會提示找不到xxxxx.dll
+ -debug-and-release . 編譯后包含兩種庫。最好編譯兩種庫
? ?-opensource ........ 編譯開源版.
? ?-commercial ........ 編譯商業版. 這兩個參數一般不需指定,configure開始需要你選擇版本。
? ?-developer-build ... 編譯開發者選項。
* -shared ............動態編譯.
? ?-static ............ 靜態鏈接庫.貌似有插件不能用靜態編譯。
* -no-fast ........... configure生成所有項目makefiles文件,并編譯
? ?-fast .............. 只生成庫目錄及子目錄下的項目的makefiles文件.
? ?-no-exceptions ..... 關閉異常支持
* -exceptions ........ 開啟異常支持.
? ?-no-accessibility .. 關閉對windows active控件支持.
* -accessibility .....對windows active控件支持.
? ?-no-stl ............ 無c++標準庫支持
* -stl ............... 有標準庫支持
尖括號在blogger出問題了。。。。。
? ?-no-sql- ... Disable SQL entirely, by default none are turned on.
? ?-qt-sql- ... Enable a SQL in the Qt Library.
? ?-plugin-sql-? ?Enable SQL as a plugin to be linked to at runtime.
? ?Available values for :
? ?mysql
? ?psql
? ?oci
? ?odbc
? ?tds
? ?db2
+ sqlite
? ?sqlite2
? ?ibase
? ?(drivers marked with a '+' have been detected as available on this system)
? ?-system-sqlite ..... Use sqlite from the operating system.
? ?-no-qt3support ..... 不提供對qt3函數支持
? ?-no-opengl ......... 不提供OpenGL函數支持
? ?-platform ... The operating system and compiler you are building on.
? ?(default %QMAKESPEC%)
? ?-xplatform .. The operating system and compiler you are cross compiling to.
? ?See the README file for a list of supported operating systems and compilers.
? ?-qtnamespace Wraps all Qt library code in 'namespace name {...}
? ?-D ........ Add an explicit define to the preprocessor.
? ?-I ... Add an explicit include path.
? ?-L ... Add an explicit library path.
? ?-l ... Add an explicit library name, residing in a librarypath.
? ?-graphicssystem Specify which graphicssystem should be used.
? ?Available values for :
* raster - Software rasterizer
? ?opengl - Using OpenGL accelleration, experimental!
? ?-help, -h, -? ...... Display this information.
第三方庫
? ?-qt-zlib ........... 使用zlib綁定到qt.
+ -system-zlib ....... 使用操作系統的zlib
? ?見 http://www.gzip.org/zlib
? ?-no-gif ............ 不編譯gif文件讀取支持插件
+ -qt-gif ............ 編譯gif文件讀取支持插件
? ?參見 src/plugins/imageformats/gif/qgifhandler.h
? ?-no-libpng ......... 不編譯PNG支持插件.
? ?-qt-libpng ......... 編譯PNG支持插件.
+ -system-libpng ..... 使用系統libpng庫
? ?見 http://www.libpng.org/pub/png
? ?-no-libmng ......... 不編譯MNG支持插件.
? ?-qt-libmng ......... 編譯MNG支持插件.
+ -system-libmng ..... 使用系統的mng庫
? ?參見 http://www.libmng.com
? ?-no-libtiff ........ 不編譯tiff支持插件.
? ?-qt-libtiff ........ 編譯tiff支持插件.
+ -system-libtiff .... 使用系統的libtiff庫
? ?見 http://www.libtiff.org
? ?-no-libjpeg ........ 不編譯jpeg支持插件庫
? ?-qt-libjpeg ........ 編譯jpeg支持插件庫
+ -system-libjpeg .... 使用系統的jpeg支持庫
? ?見 http://www.ijg.org
以下參數僅對qt for windows有效
? ?-no-dsp ............ 不生成 VC++ .dsp 文檔.
* -dsp ...............生成 VC++ .dsp文檔, 需要有平臺標識符"win32-msvc".注意 qt4開始就不支持vc6.0了所以這兩個參數無效。
? ?-no-vcproj ......... 不生成 VC++ .vcproj 文檔
* -vcproj ............ 生成 VC++ .vcproj 文檔, 需要平臺標識符"win32-msvc.net".也就是vs2003以上的編譯環境
? ?-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 the INCREDIBUILD_XGE variable.
? ?(The IncrediBuild distribution commands are only added to Visual Studio projects)
? ?-no-plugin-manifests 插件不嵌入manifests.
* -plugin-manifests .. 插件嵌入manifests.
? ?-no-qmake .......... 不編譯qmake
* -qmake ............. 編譯 qmake. 不建議 不編譯qmake
? ?-dont-process ...... 不生成makefiles和project文檔. 比 -no-fast 參數優先級更高
* -process ........... 生成makefiles和project文檔.
? ?-no-rtti ........... 不編譯運行時類型信息。
* -rtti .............. 編譯運行時類型信息。
//下面是對指令的支持,不解釋了
? ?-no-mmx ............ Do not compile with use of MMX instructions
+ -mmx ............... Compile with use of MMX instructions
? ?-no-3dnow .......... Do not compile
with use of 3DNOW instructions
+ -3dnow ............. Compile with use of 3DNOW instructions
? ?-no-sse ............ Do not compile with use of SSE instructions
+ -sse ............... Compile with use of SSE instructions
? ?-no-sse2 ........... Do not compile with use of SSE2 instructions
+ -sse2 .............. Compile with use of SSE2 instructions
+ -direct3d .......... 將Direct3D支持編譯進來。檢測不到direct3d sdk 就不支持
? ?-no-openssl ........ Do not compile in OpenSSL support
+ -openssl ........... Compile in run-time OpenSSL support
? ?-openssl-linked .... Compile in linked OpenSSL support
? ?-no-dbus ........... Do not compile in D-Bus support
+ -dbus .............. Compile in D-Bus support and load libdbus-1 dynamically
? ?-dbus-linked ....... Compile in D-Bus support and link to libdbus-1
? ?-no-phonon ......... 不將 Phonon 模塊 編譯進來
+ -phonon ............ 將 Phonon 模塊 編譯進來? ?(若使用的規范的c++編譯器則會自動編譯Phonon模塊)
? ?-no-phonon-backend . Do not compile the platform-specific Phonon backend-plu
gin
* -phonon-backend .... Compile in the platform-specific Phonon backend-plugin
? ?-no-webkit ......... 不將webkit模塊編譯進來,編譯webkit非常耗時間。
+ -webkit ............ 將webkit模塊編譯進來 (若使用的規范的c++編譯器則會自動編譯WebKit模塊)
? ?-no-scripttools .... Do not build the QtScriptTools module.
* -scripttools ....... Build the QtScriptTools module.
? ?-arch ....... 外觀樣式.
? ?有以下幾種 :
* windows
? ?windowsce
? ?boundschecker
? ?generic
? ?-no-style-尖括號里包含上面的樣式。
編譯一次Qt要耗費太多的時間,常常是越著急用它,編起來越慢。其實通過很簡單的幾招可以幫你節省編譯的時間。下面就一一道來:
第一招,編譯之前確定哪些功能是不必要的,對編譯樹進行簡單裁剪。
比如最常見的,像demos, examples,雖然很有參考價值,但完全可以放在后面用到的時候再單獨編譯小工程,這樣可以節省不少時間。經過實踐,最簡單的方法是修改configure文件,在該文件中有個指定編譯目錄的字段:
QT_DEFAULT_BUILD_PARTS=”libs tools examples demos docs translations”
可以把examples、demos和docs從這里去掉,但要注意,別的可不能隨便去掉。
如果在后面的使用中發現有些小工程需要編譯了,可以采用一般編譯Qt程序的方法,即用Qt安裝目錄bin下的qmake來生成Makefile,同樣可以編譯和測試例子代碼,一點也不影響使用。
第二招,裁剪Qt模塊。
Qt從4版本開始采用了模塊化的形式,將獨立的功能封裝在獨立的庫里,所以可以很簡單的去掉一些不需要的庫,這樣也能節省編譯時間和對硬盤空間的占用。 Qt的configure配置提供了一些設置模塊的方法,如它支持-no-svg和-no-webkit,通過configure的時候加這些選項就可以 去掉這部分支持。相應的還有很多小的功能可以通過configure參數的形式配置,具體的參考configure –help的輸出。在查看configure幫助的時候特別要注意加*號的內容,也就是Qt默認的configure選項,有的時候默認選項可不一定是討 人喜歡的哦。
Qt桌面版本默認會盡量多的編譯feature進去,這樣有一定的好處,就是用戶可以用到所有的Qt功能,但壞處也很明顯,那就是編譯出來的Qt超級大, 特別是編譯debug版本,基本上要占1到2G的空間,所以個人感覺研究一下configure的選項還是很有必要的。另外, 默認狀況下有些插件是不會編譯的,比如數據庫插件,往往需要用戶自己根據需要編譯,這一點也要注意。
第三招,針對嵌入式版本的配置。
Qt的嵌入式版本本身就支持feature裁剪,我們可以充分利用這一特性讓Qt庫盡量變小。具體的做法是要做一個自己的 qconfig-[myconfig].h特性文件,該文件中定義你要去掉Qt中的哪些feature。在configure的時候加“-qconfig myconfig” 選項, Qt就會根據你給出的配置文件來編譯,以達到裁剪的目的。這里要強調一下,這種裁剪方式只適用于嵌入式版本。這里的myconfig可以用任何你喜歡的名 字來代替。
在qt的代碼中已經給出了一些qconfig頭文件的例子,默認編譯采用full config也就是
不裁剪任何feature。所有Qt預定義好的qconfig文件,可以在src/corelib/global/下找到,包括qconfig- minimal.h, qconfig-small.h, qconfig.medium.h,qconfig-large.h和qconfig-dist.h,也就是從裁剪量由多到少都有據可依。如果要添加你自 己的配置文件,要在src/corelib/global下建立一個形如qconfig-xxx.h的文件,這個xxx也就是你要在configure的 時候傳入的qconfig參數。筆者測試使用的Qt版本是4.4.1,這個版本的build system有個小毛病,就是如果你指定的qconfig參數實際上沒有qconfig-xxx.h文件對應, build不會停止,它只會給出一個不起眼的提示,編譯過程會繼續, 這一點挺讓人費解的。而且這種情況下Qt編譯使用的配置基本上和fullconfig相同,鑒于它的讓人迷惑的舉動,個人覺得有必要提醒大家一下,使用自 定義qconfig的時候一定要確定配置文件放對了位置,而且qconfig參數給的正確。
一般我們的建議是在桌面上測試階段編譯一個full的版本,再根據你的項目使用Qt feature的情況總結哪些可去掉的feature。 feature之間有千絲萬縷的依賴關系,這個問題也是困擾很多人的難點所在。具體的依賴可以查閱src/corelib/global /qfeatures.h和src/corelib/global/qfeatures.txt(描述依賴關系的文檔)。另外,Qt里還提供了一個可視化 的配置依賴的工具,叫做qconfig,在QTDIR/tools/qconfig目錄。該工具需要基于Qt桌面版本編譯。如在我的linux系統下可以 用下面的命令來編譯:
$ cd qt-embedded-linux-commercial-4.4.1/tools/qconfig
$ /usr/local/Trolltech/Qt-4.4.3/bin/qmake
$ make
編譯成功后運行./qconfig,初始要打開qfeatures.txt. Qconfig讀取該文件生成一個樹狀圖,該圖很清楚的顯示出feature之間的依賴關系。如下圖所示,如果你去掉了LINEEDIT這個 feature,用到該控件的combobox也就不能繼續使用了。有了這個工具裁剪Qt變得簡潔直觀,方便了很多。
選定了你要去掉的feature后點擊菜單File->Save As..會彈出保存文件的頁面,文件名字應該定義成qconfig-xxx.h的形式,這樣你在configure的時候就可以傳入相應的qconfig 參數了。你還可以通過選擇File->Open打開現有的qconfig-xxx.h文件,通過修改已經有的文件更快的編輯配置。
根據筆者測試,未經裁剪的qte4.4.1編譯出來為:
libQtCore.so是2.6M
libQtGui.so是9.5M
如果用small來編譯,就能縮小為:
libQtCore.so是2.0M
libQtGui.so是5.7M
差異還是比較明顯的。
轉載于:https://www.cnblogs.com/elect-fans/archive/2012/03/28/2420647.html
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的Qt configure 参数不完全说明的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 苹果开始招聘6G研发工程师 从事下一代6
- 下一篇: 神舟KP7怎么U盘启动 神舟KP7如何使