I. statically compile the QT Library
To enable the QT program to run in environments without QT dependency libraries, You need to compile your QT program statically. To achieve this goal, you must first compile your QT library file statically. The process is as follows:
My system: ubuntu10.10
Step 1: Download the source code package
Qt-everywhere-opensource-src-4.7.1.tar.gz ().
Step 2: Extract
Tar zxvf qt-everywhere-opensource-src-4.7.1.tar.gz
Step 3: Configure
1. Enter the extract Directory: CD qt-everywhere-opensource-src-4.7.1,
2. configure compilation options :. /configure-release-static-nomake examples-nomake demos-no-qt3support-no-script-no-scripttools-no-multimedia-no-audio-backend-no-OpenSSL-no-OpenGL -No-WebKit-no-phonon-no-SQL-SQLite
-Release: compiled version
-Static: static compilation. This option must be selected.
The following parameters are selective compilation. To speed up compilation, I removed some modules (-no-removed module names)
Step 4: Compile and install
Make
Make install
Step 5: Set Environment Variables
Run gedit ~ /. Bashrc Add the following content: qtdir =/usr/local/trolltech/Qt-4.7.1/Path = $ qtdir/bin: $ PATH manpath = $ qtdir/doc/man: $ manpath LD_LIBRARY_PATH = $ qtdir/lib: $ LD_LIBRARY_PATH export qtdir path manpath LD_LIBRARY_PATH
Restart the terminal: qmake-V is successfully compiled and installed if the following result is displayed:
Qmake version 2.01a using QT version 4.7.1 in/usr/local/trolltech/Qt-4.7.1/lib
Ii. Static compiling of QT applications
The preceding two methods can be used:
1. Add qmake_lflags + =-static to the. Pro file,
2. Add the static option to the MAKEFILE file:
Find the makefile in the program directory and modify the MAKEFILE file as follows:
Cxxflags =-static-pipe-wall-w-O2-fomit-frame-pointer-pipe-March = i586-mcpu = pentiumpro-dqt_no_debug-dqt_shared-dqt_thread_support
Then execute make, and you will find that your executable file is much larger than that of dynamic compilation.
References:
[1]: http://jingyan.baidu.com/article/ea24bc39403ef6da62b331cf.html
[2]: http://www.dnbcw.com/biancheng/linux/skjw302922.html
[3]: http://hi.baidu.com/cyclone/blog/item/25b262d9337a172310df9b78.html
[4]: http://www.programfan.com/blog/article.asp? Id = 47480