QT4.8.4 靜態編譯及壓縮

1.下載qt 4.8.4的源代碼qt-everywhere-opensource-src-4.8.4.zip,解壓到路徑任意,如d:\qt-src-4.8.4sql

2.刪除源碼包中bin目錄下的syncqt和syncqt.dat文件。如不修改將發生 Perl not found in environment - cannot run syncqt 錯誤。windows

3.修改\mkspecs\win32-msvc2010下的qmake.conf文件,將其中的ui

QMAKE_CFLAGS=-nologo -Zm200 -Zc:wchar_t-  

改成: QMAKE_CFLAGS
=-nologo -Zm200 -Zc:wchar_t (注意末尾的」-「號區別)

4.搜索整個qmake.conf文件,將MD,MDd對應改爲MT,MTd,以實如今沒有VC庫的電腦也能運行Qt程序。this

5.VS命令行窗口下進入剛纔解壓路徑如d:\qt-src-4.8.4,使用以下命令生成makefilespa

 

configure -debug-and-release -fast -static -platform win32-msvc2010 -no-qt3support -script -scripttools -qt-zlib -qt-libpng -qt-libmng -qt-libtiff -qt-libjpeg -qt-sql-sqlite -plugin-sql-sqlite -qt-style-windows -qt-style-windowsxp -qt-style-windowsvista -qt-style-plastique -qt-style-cleanlooks -qt-style-motif -qt-style-cde -nomake demos -nomake examples -nomake docs -mp

-debug-and-release -static表示靜態編譯debug與release版本Qt.-mp表示多核同時編譯。命令行

6. VS命令行窗口下輸入nmake, 開始編譯過程,此過程依機器CPU水平決定時間多少,通常耗時約2hrs。如無錯誤提示即實現了靜態編譯。debug

7.編譯完便可使用vs-addin實現Qt程序的編寫,且編寫好的程序無需任何dlls,只是容量較大,一個簡單的程序也須要10+m的空間。這時可以使用UPX來壓縮exe文件,壓縮語句以下:code

 

Usage: upx [-123456789dlthVL] [-qvfk] [-o file] file..

Commands:
   -1     compress faster                -9 compress better
   --best compress best (can be very slow for big files)
   -d     decompress                      -l list compressed file
   -t     test compressed file              -V display version number
   -h     give this help                    -L display software license

Options:
   -q     be quiet                          -v be verbose
   -oFILE write output to `FILE'
   -f     force compression of suspicious files
   --no-color, --mono, --color, --no-progress change look

Backup options:
   -k, --backup        keep backup files
   --no-backup       no backup files [default]

Overlay options:
   --overlay=skip    don't compress a file with an overlay
   --overlay=copy    copy any extra data attached to the file [default]
   --overlay=strip     strip any extra data attached to the file [dangerous]

Options for dos/exe:
   --8086              make compressed exe work on any 8086
   --no-reloc       put no relocations in to the exe header

Options for dos/com:
   --8086              make compressed com work on any 8086

Options for dos/sys:
   --8086              make compressed sys work on any 8086

Options for djgpp2/coff:
   --coff              produce COFF output [default: EXE]

Options for watcom/le:
   --le             produce LE output [default: EXE]
相關文章
相關標籤/搜索