QT4.8.4 静态编译及压缩

1.下载qt 4.8.4的源代码qt-everywhere-opensource-src-4.8.4.zip,解压到路径任意,如d:\qt-src-4.8.4

2.删除源码包中bin目录下的syncqt和syncqt.dat文件。如不修改将发生 Perl not found in environment - cannot run syncqt 错误。

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

QMAKE_CFLAGS=-nologo -Zm200 -Zc:wchar_t-  

改为: QMAKE_CFLAGS
=-nologo -Zm200 -Zc:wchar_t (注意末尾的”-“号区别)

4.搜索整个qmake.conf文件,将MD,MDd对应改成MT,MTd,以实现在没有VC库的电脑也能运行Qt程序。

5.VS命令行窗口下进入刚才解压路径如d:\qt-src-4.8.4,使用如下命令生成makefile

 

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。如无错误提示即实现了静态编译。

7.编译完即可使用vs-addin实现Qt程序的编写,且编写好的程序无需任何dlls,只是容量较大,一个简单的程序也需要10+m的空间。这时可使用UPX来压缩exe文件,压缩语句如下:

 

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]

 

  

 

 

 

posted on 2013-07-03 15:51  ric  阅读(1583)  评论(0编辑  收藏  举报

导航