Visual Studio 2008 (including Express Edition) integrates with QT 4.5 (all versions with 4.5) __QT

Source: Internet
Author: User
Tags odbc openssl sqlite

Note: This installation method also applies to QT version 4.6.

For space reasons, all the pictures in the text are omitted.

Here we take Ms Visual Studio version 2008 as an example to illustrate the integrated use of QT 4.5, which is also useful for express series. The VS 2005 integrated configuration method with Qt 4.5 is similar to this, except that when you install VS 2005, you need to have a SP1 patch. We recommend using VS 2008 more.

According to QT Software, since Qt 4.6, QT will provide a direct installation version of the MS Visual Studio series, a move that will greatly simplify the installation configuration process. However, this version of the built-in functionality does not necessarily meet the needs of developers, so this article introduces the compiler installation method is of universal significance, I hope we can grasp the heart.

The following is an example of the Chinese version of Windows XP SP2, which describes how to integrate the two.

Step 1th, install MS Visual Studio 2008

In this step, there are two points to note. First, you can choose the English version or the Chinese version, the entire installation process is not a big difference. When using the Chinese version, either vs 2008 or 2005 need to install the VS SP1 package, or an error occurs, causing the installation to fail. I personally like the use of English version, the second is installed, the best choice to complete the installation of the way, of course, will not use the language and modules such as VB and C # can not be selected, VC all components to install up. A lot of friends on the internet there are some problems when installed, many of the VS installation is not installed completely related.

Step 2nd, install the QT 4.5 source code

Download the QT SDK on the official website and install it by default (the unfamiliar friend can refer to the 2nd chapter), note that the version is at any time may be updated, the official website address is: Here we choose Lgpl/free Downloads, then select

Decompression, assuming decompression to e:/qt-win-opensource-src-4.5.0, note that the decompression path does not include spaces, Chinese names and other special characters, after decompression directory level as shown in Figure 4-14.

Step 3rd, configure environment variables

The main is to set up two environment variables, using the command line method as follows:

Set qtdir=e:/qt-win-opensource-src-4.5.0
Set Path=%path%;%qtdir%/bin

The following methods are used for graphical settings:

Click "My Computer"-> "Properties"-> "Advanced"-> "Environment variables", pop-up "Environment variables" Settings dialog box, as shown in Figure 4-15.

Then click on the "New" button, pop-up "New User Variable" dialog box, in which the input box to fill in:

"Variable name"---qtdir

"Variable Value"---e:/qt-win-opensource-src-4.5.0

Similar to the previous steps, the PATH environment variable is modified by the following methods:

As shown in Figure 4-16, select the "PATH" variable and click the "Edit" button to enter the last face of the "variable value":


Note that there is a semicolon at the front (not a semicolon in Chinese, remember).

Step 4th, use vs to compile Qt source

It is best to prepare a directory for the Qt SDK, such as mine: E:/QT/4.5SDK. Note The format of the disk is formatted as FAT 32, and the NTFS format may affect the installation process.

Then you start compiling the QT 4.5 source code.

-> Microsoft Visual Studio 2008-> "Visual Studio Tools" from the Start menu to run the VS 2008 command-line prompt, the middle process is as follows:

1 c:/program files/microsoft Visual Studio 9.0/vc> CD C:/Program files/microsoft Visual Studio 8/common7/tools>
2 C:/Program files/microsoft Visual Studio 8/common7/tools> vsvars32.bat
3 C:/Program files/microsoft Visual Studio 8/common7/tools> e:
4 e:/> CD E:/QT/4.5SDK/QT
5 e:/qt/4.5sdk/qt> Configure-platform Win32-msvc2008-debug-and-release
6 e:/qt/4.5sdk/qt> NMAKE

Using the current mainstream machine configuration, configure this step will take about an hour. Namke about three hours. There may be some warning in the middle that can be ignored.

Line 1th and 2nd, is the configuration of VC environment variables, how to know that the environment variables have been configured well. The method is run at the command line:

If the Cl.exe help description information is exported, the VC compiler environment variable setting is successful.

Tip: At the command line, you can view the settings of the path, include, and LIB environment variables by entering commands such as set path, set include, and set Lib.

The Configure command mainly does two things.

One is to compile the qmake and copy the compiled Qmake.exe to the bin directory (which is why you add "%qtdir%/bin" to the PATH environment variable).

The second is to generate makefile files (including makefile files for compiling QT and makefiles files for examples, demos, tools, etc.).

The use of configure is to be carefully thought out, you can see the specific options by adding the-H parameter, some options are preceded by * to indicate that the default is selected, and the + number indicates that the system determines whether the option is supported. Table 4-2 lists the commonly used parameters for the Configure command.

Table 4-2 Common parameters for configure commands

Compile the shared version (default compiled to Shared edition, no setup required), and compile debug and release two versions


Use vc2008 (including Express Edition)

-platform win32-msvc2008

zlib, GIF, libpng, libmng, Libtiff, libjpeg with QT


Compiling database Plug-ins support SQLite, ODBC (requires support for the corresponding C + + header files and libraries)


QT3 not supported


No MMX instruction set support


No 3DNow instruction Set support


No SSE and SSE2 instruction set support


No Direct3D Support (Direct3D not compiled by default)


No OpenSSL support


No Dbus support


No phonon support and phonon backward compatibility support


Do not compile WebKit module


Scripting Tools not supported Scripttools


Do not generate SLN and vcproj files, only generate makefile


Using the parameters listed in the table, their corresponding configure commands are as follows:

Configure-debug-and-release-platform Win32-msvc2008-qt-zlib-qt-gif-qt-libpng-qt-libmng-qt-libtiff-qt-libjpeg- Plugin-sql-sqlite-plugin-sql-odbc-no-qt3support-no-mmx-no-3dnow-no-sse-no-sse2-no-openssl-no-dbus-no-phonon- No-phonon-backend-no-webkit-no-scripttools-no-dsp-no-vcproj

After the compilation is complete, it is best to clean up to save hard disk space and enter at the command line:

After this cleanup is complete, the entire QT decompression directory is about 800M in size.

The 5th step, and finally, the QT path is added to the VC build environment.

Turn on the tools-> option-> Project and Solution-> "VC + + catalog."

Add in the Include file column:




Add in the Library file column:


Add the QT installation path to the path system environment variable, for example: E:/qt-win-opensource-src-4.5.0/bin (This step can be omitted and is already set up earlier in this article).

Step 6th, install the Qt for VS plug-in

To make

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: 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.