- 論壇徽章:
- 0
|
只需要加個(gè) -fast參數(shù)就ok了。其他參數(shù)視自己情況而定,比如你不需要qt3支持可以添加-no-qt3support,或者不需要webkit插件 -no-webkit
配置參數(shù)選項(xiàng):
前面是*號(hào)的表示默認(rèn)參數(shù). +號(hào)表示該功能要求被評(píng)估,評(píng)估成功后才能被接受.
-release ........... 調(diào)試關(guān)閉.沒(méi)有調(diào)試庫(kù),自己的項(xiàng)目只能發(fā)布,不能調(diào)試(沒(méi)有調(diào)試庫(kù)的緣故),如果你硬要編譯debug版本的話,會(huì)提示找不到xxxxxd.dll
* -debug ............. 只有調(diào)試庫(kù),沒(méi)有釋放庫(kù),也就是說(shuō)以后自己的項(xiàng)目只能調(diào)試,如果你硬要編譯debug版本的話,會(huì)提示找不到xxxxx.dll
+ -debug-and-release . 編譯后包含兩種庫(kù)。最好編譯兩種庫(kù)
-opensource ........ 編譯開源版.
-commercial ........ 編譯商業(yè)版. 這兩個(gè)參數(shù)一般不需指定,configure開始需要你選擇版本。
-developer-build ... 編譯開發(fā)者選項(xiàng)。
* -shared ............動(dòng)態(tài)編譯.
-static ............ 靜態(tài)鏈接庫(kù).貌似有插件不能用靜態(tài)編譯。
* -no-fast ........... configure生成所有項(xiàng)目makefiles文件,并編譯
-fast .............. 只生成庫(kù)目錄及子目錄下的項(xiàng)目的makefiles文件.
-no-exceptions ..... 關(guān)閉異常支持
* -exceptions ........ 開啟異常支持.
-no-accessibility .. 關(guān)閉對(duì)windows active控件支持.
* -accessibility .....對(duì)windows active控件支持.
-no-stl ............ 無(wú)c++標(biāo)準(zhǔn)庫(kù)支持
* -stl ............... 有標(biāo)準(zhǔn)庫(kù)支持
尖括號(hào)在blogger出問(wèn)題了。。。。。
-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 ..... 不提供對(duì)qt3函數(shù)支持
-no-opengl ......... 不提供OpenGL函數(shù)支持
-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.
第三方庫(kù)
-qt-zlib ........... 使用zlib綁定到qt.
+ -system-zlib ....... 使用操作系統(tǒng)的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 ..... 使用系統(tǒng)libpng庫(kù)
見 http://www.libpng.org/pub/png
-no-libmng ......... 不編譯MNG支持插件.
-qt-libmng ......... 編譯MNG支持插件.
+ -system-libmng ..... 使用系統(tǒng)的mng庫(kù)
參見 http://www.libmng.com
-no-libtiff ........ 不編譯tiff支持插件.
-qt-libtiff ........ 編譯tiff支持插件.
+ -system-libtiff .... 使用系統(tǒng)的libtiff庫(kù)
見 http://www.libtiff.org
-no-libjpeg ........ 不編譯jpeg支持插件庫(kù)
-qt-libjpeg ........ 編譯jpeg支持插件庫(kù)
+ -system-libjpeg .... 使用系統(tǒng)的jpeg支持庫(kù)
見 http://www.ijg.org
以下參數(shù)僅對(duì)qt for windows有效
-no-dsp ............ 不生成 VC++ .dsp 文檔.
* -dsp ...............生成 VC++ .dsp文檔, 需要有平臺(tái)標(biāo)識(shí)符"win32-msvc".注意 qt4開始就不支持vc6.0了所以這兩個(gè)參數(shù)無(wú)效。
-no-vcproj ......... 不生成 VC++ .vcproj 文檔
* -vcproj ............ 生成 VC++ .vcproj 文檔, 需要平臺(tái)標(biāo)識(shí)符"win32-msvc.net".也就是vs2003以上的編譯環(huán)境
-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 參數(shù)優(yōu)先級(jí)更高
* -process ........... 生成makefiles和project文檔.
-no-rtti ........... 不編譯運(yùn)行時(shí)類型信息。
* -rtti .............. 編譯運(yùn)行時(shí)類型信息。
//下面是對(duì)指令的支持,不解釋了
-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支持編譯進(jìn)來(lái)。檢測(cè)不到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 模塊 編譯進(jìn)來(lái)
+ -phonon ............ 將 Phonon 模塊 編譯進(jìn)來(lái) (若使用的規(guī)范的c++編譯器則會(huì)自動(dòng)編譯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模塊編譯進(jìn)來(lái),編譯webkit非常耗時(shí)間。
+ -webkit ............ 將webkit模塊編譯進(jìn)來(lái) (若使用的規(guī)范的c++編譯器則會(huì)自動(dòng)編譯WebKit模塊)
-no-scripttools .... Do not build the QtScriptTools module.
* -scripttools ....... Build the QtScriptTools module.
-arch ....... 外觀樣式.
有以下幾種 :
* windows
windowsce
boundschecker
generic
-no-style-尖括號(hào)里包含上面的樣式。
編譯一次Qt要耗費(fèi)太多的時(shí)間,常常是越著急用它,編起來(lái)越慢。其實(shí)通過(guò)很簡(jiǎn)單的幾招可以幫你節(jié)省編譯的時(shí)間。下面就一一道來(lái):
第一招,編譯之前確定哪些功能是不必要的,對(duì)編譯樹進(jìn)行簡(jiǎn)單裁剪。
比如最常見的,像demos, examples,雖然很有參考價(jià)值,但完全可以放在后面用到的時(shí)候再單獨(dú)編譯小工程,這樣可以節(jié)省不少時(shí)間。經(jīng)過(guò)實(shí)踐,最簡(jiǎn)單的方法是修改configure文件,在該文件中有個(gè)指定編譯目錄的字段:
QT_DEFAULT_BUILD_PARTS=”libs tools examples demos docs translations”
可以把examples、demos和docs從這里去掉,但要注意,別的可不能隨便去掉。
如果在后面的使用中發(fā)現(xiàn)有些小工程需要編譯了,可以采用一般編譯Qt程序的方法,即用Qt安裝目錄bin下的qmake來(lái)生成Makefile,同樣可以編譯和測(cè)試?yán)哟a,一點(diǎn)也不影響使用。
第二招,裁剪Qt模塊。
Qt從4版本開始采用了模塊化的形式,將獨(dú)立的功能封裝在獨(dú)立的庫(kù)里,所以可以很簡(jiǎn)單的去掉一些不需要的庫(kù),這樣也能節(jié)省編譯時(shí)間和對(duì)硬盤空間的占用。 Qt的configure配置提供了一些設(shè)置模塊的方法,如它支持-no-svg和-no-webkit,通過(guò)configure的時(shí)候加這些選項(xiàng)就可以 去掉這部分支持。相應(yīng)的還有很多小的功能可以通過(guò)configure參數(shù)的形式配置,具體的參考configure –help的輸出。在查看configure幫助的時(shí)候特別要注意加*號(hào)的內(nèi)容,也就是Qt默認(rèn)的configure選項(xiàng),有的時(shí)候默認(rèn)選項(xiàng)可不一定是討 人喜歡的哦。
Qt桌面版本默認(rèn)會(huì)盡量多的編譯feature進(jìn)去,這樣有一定的好處,就是用戶可以用到所有的Qt功能,但壞處也很明顯,那就是編譯出來(lái)的Qt超級(jí)大, 特別是編譯debug版本,基本上要占1到2G的空間,所以個(gè)人感覺研究一下configure的選項(xiàng)還是很有必要的。另外, 默認(rèn)狀況下有些插件是不會(huì)編譯的,比如數(shù)據(jù)庫(kù)插件,往往需要用戶自己根據(jù)需要編譯,這一點(diǎn)也要注意。
第三招,針對(duì)嵌入式版本的配置。
Qt的嵌入式版本本身就支持feature裁剪,我們可以充分利用這一特性讓Qt庫(kù)盡量變小。具體的做法是要做一個(gè)自己的 qconfig-[myconfig].h特性文件,該文件中定義你要去掉Qt中的哪些feature。在configure的時(shí)候加“-qconfig myconfig” 選項(xiàng), Qt就會(huì)根據(jù)你給出的配置文件來(lái)編譯,以達(dá)到裁剪的目的。這里要強(qiáng)調(diào)一下,這種裁剪方式只適用于嵌入式版本。這里的myconfig可以用任何你喜歡的名 字來(lái)代替。
在qt的代碼中已經(jīng)給出了一些qconfig頭文件的例子,默認(rèn)編譯采用full config也就是
不裁剪任何feature。所有Qt預(yù)定義好的qconfig文件,可以在src/corelib/global/下找到,包括qconfig- minimal.h, qconfig-small.h, qconfig.medium.h,qconfig-large.h和qconfig-dist.h,也就是從裁剪量由多到少都有據(jù)可依。如果要添加你自 己的配置文件,要在src/corelib/global下建立一個(gè)形如qconfig-xxx.h的文件,這個(gè)xxx也就是你要在configure的 時(shí)候傳入的qconfig參數(shù)。筆者測(cè)試使用的Qt版本是4.4.1,這個(gè)版本的build system有個(gè)小毛病,就是如果你指定的qconfig參數(shù)實(shí)際上沒(méi)有qconfig-xxx.h文件對(duì)應(yīng), build不會(huì)停止,它只會(huì)給出一個(gè)不起眼的提示,編譯過(guò)程會(huì)繼續(xù), 這一點(diǎn)挺讓人費(fèi)解的。而且這種情況下Qt編譯使用的配置基本上和fullconfig相同,鑒于它的讓人迷惑的舉動(dòng),個(gè)人覺得有必要提醒大家一下,使用自 定義qconfig的時(shí)候一定要確定配置文件放對(duì)了位置,而且qconfig參數(shù)給的正確。
一般我們的建議是在桌面上測(cè)試階段編譯一個(gè)full的版本,再根據(jù)你的項(xiàng)目使用Qt feature的情況總結(jié)哪些可去掉的feature。 feature之間有千絲萬(wàn)縷的依賴關(guān)系,這個(gè)問(wèn)題也是困擾很多人的難點(diǎn)所在。具體的依賴可以查閱src/corelib/global /qfeatures.h和src/corelib/global/qfeatures.txt(描述依賴關(guān)系的文檔)。另外,Qt里還提供了一個(gè)可視化 的配置依賴的工具,叫做qconfig,在QTDIR/tools/qconfig目錄。該工具需要基于Qt桌面版本編譯。如在我的linux系統(tǒng)下可以 用下面的命令來(lái)編譯:
$ cd qt-embedded-linux-commercial-4.4.1/tools/qconfig
$ /usr/local/Trolltech/Qt-4.4.3/bin/qmake
$ make
編譯成功后運(yùn)行./qconfig,初始要打開qfeatures.txt. Qconfig讀取該文件生成一個(gè)樹狀圖,該圖很清楚的顯示出feature之間的依賴關(guān)系。如下圖所示,如果你去掉了LINEEDIT這個(gè) feature,用到該控件的combobox也就不能繼續(xù)使用了。有了這個(gè)工具裁剪Qt變得簡(jiǎn)潔直觀,方便了很多。
選定了你要去掉的feature后點(diǎn)擊菜單File->Save As..會(huì)彈出保存文件的頁(yè)面,文件名字應(yīng)該定義成qconfig-xxx.h的形式,這樣你在configure的時(shí)候就可以傳入相應(yīng)的qconfig 參數(shù)了。你還可以通過(guò)選擇File->Open打開現(xiàn)有的qconfig-xxx.h文件,通過(guò)修改已經(jīng)有的文件更快的編輯配置。
根據(jù)筆者測(cè)試,未經(jīng)裁剪的qte4.4.1編譯出來(lái)為:
libQtCore.so是2.6M
libQtGui.so是9.5M
如果用small來(lái)編譯,就能縮小為:
libQtCore.so是2.0M
libQtGui.so是5.7M
差異還是比較明顯的。 |
|