Go to a more detailed article on compiling QT with VC

Source: Internet
Author: User
From: http://www.pin5i.com/showtopic-qt-vs2005-vs2008-mingw-static-compilation.html

 

Compilation preparation Download the qt sdk on the Nokia website, decompress the SDK, or install it to the relevant directory. This document uses QT 4.6.2 as an example. For example, skip (assuming that it is installed on D: \ QT ): unzip-share unzip-lib unzip-bin unzip-mingw unzip-QT unzip-translations (QT language file directory) unzip-tools (QT-related tool source code directory) unzip-Src ( Source code Directory) named-qmake (qmake Source Code Directory) ─ ── plugins (directory for graphics, databases, and other plug-ins) ── mkspecs (platform configuration file) ├ ── lib (library file) ├ ── include (header file) ─ ── examples (example) Program ) Demo-doc (document) demo-demos (Demo program) demo-config. the tests ‑bin (command line tool) ‑qtc-debugging-helperconfigure Configuration tool is in the QT directory. Assume that qtdir = D: \ QT \ SDK \ QT, before compilation, it is best to clear the Lib, demos, examples, and docs directories. After the configuration is complete, place an empty makefile in these directories to avoid making errors. Dynamic vs2005 Compilation 1. set the environment variable of vs2005 2. set the destination platform set qmakespec = win32-msvc20053. go to the qtdir directory to run the configuration, generate the MAKEFILE file configure-platform win32-msvc2005-release-opensource-shared-fast-QT-SQL-SQLite-plugin-SQL-SQLite-no-qt3support-QT-zlib-QT-GIF-QT- libpng-QT-libmng-QT-LibTIFF-QT-libjpeg-no-WebKit-QT-style-WindowsXP-qt-style-windowsvista4. run nmake/I/K (with the/I/K option to avoid automatic termination of Compilation When an error occurs, used to skip the error and continue compiling other files). The QT library compiled by this method does not depend on mingwm10.dll, Li Bgcc_s_dw2-1.dll, but rely on the qt library DLL files and Microsoft CRT Runtime Library, use this QT library to compile programs on Windows platforms, the QT Link Library DLL file and Microsoft CRT Runtime Library DLL file must be included during release. Vs2005 static Compilation (Similarly, when vs2008 is compiled, start the corresponding command line, set the corresponding target platform, and modify the corresponding configuration file) 1. set the environment variable of vs2005 2. set the destination platform set qmakespec = win32-msvc20053. modify the configuration file qmake in the mkspecs/win32-msvc2005 directory. conf: Change qmake_cflags_release =-O2-mdqmake_cflags_debug =-Zi-MDD to qmake_cflags_release =-O2-Primary =-Zi-MTD (d Refers to dynamic, T refers to static, d Refers to debug) 4. go to the qtdir directory and run the configuration to generate the MAKEFILE file set qmakespec = win32-msvc2005configure-platform win32-msvc2005-release-n O-exceptions-opensource-static-fast-QT-SQL-SQLite-plugin-SQL-SQLite-no-qt3support-QT-zlib-QT-GIF-QT-libpng-QT-libmng- qt-LibTIFF-QT-libjpeg-no-WebKit-QT-style-WindowsXP-qt-style-windowsvista5. the QT library compiled for running nmake/I/K does not depend on any DLL files (such as Microsoft's CRT Runtime Library ), you do not need to attach any additional DLL files when you use this QT library to compile programs on Windows. Mingw static Compilation 1. set the mingw environment variable 2. set the target platform set qmakespec = win32-g ++ 3. modify the configuration file qmake in the mkspecs/win32-g ++ directory. conf changes the following line: qmake_lflags =-enable-stdcall-fixup-wl,-enable-auto-import-wl,-enable-runtime-pseudo-reloc: qmake_lflags =-static-enable-stdcall-fixup-wl,-enable-auto-import-wl,-enable-runtime-pseudo-reloc, and then put the following line: qmake_lflags_dll =-shared to: qmake_lflags_dll =-static4.qtdir directory, run the configuration, generate MAKEFILE file set qmakespec = win32-g + Configure-platform win32-g + +-release-no-exceptions-opensource-static-fast-QT-SQL-SQLite-plugin-SQL-SQLite-no-qt3support-QT-zlib-QT -GIF-QT-libpng-QT-libmng-QT-LibTIFF-QT-libjpeg-no-WebKit-QT-style-WindowsXP-qt-style-windowsvista5. run the mingw32-make-I-K (the meaning of the-I-K option is the same as that of nmake above) after such a compiled QT library, independent of any DLL file (such as mingwm10.dll, libgcc_s_dw2-1.dll ), you do not need to attach any additional DLL files when releasing a program compiled using this QT library on Windows. Compilation instructions After compilation, you can delete all files not on the current compilation date in the bin directory. We recommend that you remove all files in the examples and Demos folders before compilation to avoid re-compiling these two folders and speed up compilation. In addition, Please configure the compilation command according to your actual situation. The above configuration is (take vs2005 static compilation as an example ): -Platform win32-msvc2005 target platform-release disable debugging information-no-exceptions remove exceptions support-opensource Open Source-static create static library-fast quick configuration, only generate makefile files of QT library files and subdirectories, other makefile files are subsequently generated using qmake-QT-SQL-SQLite driver support-plugin-SQL-SQLite link plug-in support-no-qt3support does not compile qt3 compatible library-QT-zlib library-QT-GIF-QT-libpng-QT-libmng-QT-LibTIFF-QT-libjpeg image format plug-in library-no-WebKit does not compile WebKit, this option can greatly speed up compilation. You can delete this option by using WebKit. Option-QT-style-WindowsXP-QT-style-windowsvista supports XP and vistatheme styles. Note: static compilation programs are usually large. We recommend that you use UPX compression before release, generally, it can reduce the size by at least 50%.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.