Qt 4.5And
Visual StudioIntegration
This article describes how to use QT
4.5 and
Visual Studio 2008 integration, also applicable to visual
Studio 2005,200 3.
Qt 4.5
Although the lgpl protocol is added, this also hinders the use of QT in. Because the free open-source version only provides the binary library compiled by GCC, and does not have the binary library compiled by VC, only the commercial version has the DLL compiled by vs for Windows, lib and other binary libraries (well, you can understand ).
In addition, the VC compiler is better than the GCC
It is still much more powerful, and the debugger is exceptionally powerful. Qt
Although cool, creator is still rough. Many people are more familiar with vs interfaces.
Next we will compile the binary library with vs, and then we can be the same as the commercial version.
However, you can also Google "QT
4.5 compiled. "find the binary library that has been compiled by many people and download it and use it directly. The following content does not show ^_^
1. Download and install
Qt-sdk-win-opensource-2009.01.exe, installed to the default
C:/QT/2009.01. It contains the minggw and
Qt creator and pre-compiled binary files (Compiled with GCC ). You can directly use QT
Creator starts development without any additional configuration.
2. Set the entire directory
C:/QT/2009.01 copy one copy
C:/QT/4.5.0-VC. We will modify the directory c:/QT/4.5.0-VC and use VC ++ to compile the required library. These two directories can exist at the same time. QT uses C:/QT/2009.01, visual
Studio usage
C:/QT/4.5.0-VC.
3. Modify
C:/program files/Microsoft Visual Studio
9.0/common7/tools/
Vsvars32.bat: add the QT directory to the environment variable path, as shown in figure
C:/QT/4.5.0-VC/Qt, in include
Tian
Add C:/QT/4.5.0-VC/QT/include in lib
C:/QT/4.5.0-VC/QT/include, for example:
@ Set
Path = C:/QT/4.5.0-VC/Qt; C:/program files/Microsoft Visual Studio
9.0/common7/ide; C:/program files/Microsoft Visual Studio
9.0/VC/bin; C:/program files/Microsoft Visual Studio
9.0/common7/tools; C:/Windows/Microsoft. NET/framework/v3.5; C:/Windows/Microsoft. NET/framework/v2.0.50727; C:/Program
Files/Microsoft Visual Studio 9.0/VC/vcpackages; % PATH %
@ Set
Include = C:/QT/4.5.0-VC/QT/include; C:/program files/Microsoft Visual
Maxcompute studio 9.0/VC/atlmfc/include; C:/program files/Microsoft Visual Studio
9.0/VC/include; % include %
@ Set
Lib = C:/QT/4.5.0-VC/QT/LIB; C:/program files/Microsoft Visual Studio
9.0/VC/atlmfc/LIB; C:/program files/Microsoft Visual Studio
9.0/VC/LIB; % lib %
Open a cmd command line window and drag the file for execution. In this way, the CMD you open has the environment variables set above, but these variables are only for your current cmd, does not change the local configuration, so do not close the CMD window, you need to complete the following commands in this cmd window.
(This step is absent from many websites,
Will cause the following configure to fail)
4. Execute
C:/>
Cd c:/QT/4.5.0-VC/QT
C:/QT/4.5.0-VC/Qt>
Configure-no-SQL-SQLite-no-qt3support-no-OpenGL-Platform
Win32-msvc2008-no-LibTIFF-no-encoding-no-phonon-backend
-No-WebKit
You can modify the above command as needed, but be sure to specify
-Platform
The following parameter indicates the version of Vs to be configured. For example, if you want to compile it into vs2005 (the premise is that you have installed vs2005), replace it
Win32-msvc2005. In this step, a makefile is generated for nmake compilation to generate all libraries. This step takes about 30 minutes.
5. Enter
Nmake, press enter to start compilation. This step is a long one. I have compiled it for about three hours ~~
Note:If you are a Windows
In 7, most failures will occur, because win
7
The SDK has bugs. When binary does not have the resouce region, the MT program cannot add manifest to binary (refer to: http://download.microsoft.com/download/8/8/0/8808A472-6450-4723-9C87-977069714B27/ReleaseNotes.Htm), so we need to make some modifications,
Step 1: run the following command in cmd:
C:/QT/4.5.0-VC/Qt> echo.> hello. RC
C:/QT/4.5.0-VC/Qt>
Rc.exe/R hello. RC
Get
C:/QT/4.5.0-VC/QT/Hello. Res resource file.
Step 2: Modify the qmake configuration file so that the makefile link command links hello. Res to binary. Modify qmake. conf file 52nd behavior under the mkspecs/win32-msvc2005 directory
Qmake_lflags =/nologo C:/QT/4.5.0-VC/QT/Hello. Res
In this way, any link command will inevitably link the hello. Res file.
Then you can enter nmake to start compilation.
6.
Install official vsplug-In qt-vs-addin-1.0.0-beta.exe,
7. Start
Visual Studio, select the menu "QT-> QT
Options ", in"
On the qt ons tab, click
"Add", version
Name, for example
"Qt4.5.0-VC", enter the path
"C:/QT/4.5.0-VC/Qt ". (According to the online documents, the environment variable qtdir = needs to be created.
C:/QT/4.5.0-VC/Qt, which I personally think is unnecessary ).
8. Now your visual
Studio has all functions of QT and creates a new QT
Compile and run the project!
(After compilation, click debug-Debug under
Without debuggine can see the effect of the program running,
If you double-click the EXE file in the DEBUG directory, the system will prompt that the qtcore4d file cannot be found. DLL. In this case, you need to add C:/QT/4.5.0-VC/QT/bin to the path environment variable. The directory also contains qtcore4.dll, which is compiled above ).
However, your current environment is integrated with lgpl QT vs, which is a little different from the commercial version. For example, QT
Desiner (Resource Designer) is not embedded in vs. You need to use the menu "QT-> launch
"Desiner" to execute (for Business Edition, double-click the. UI file to start QT
Desiner ). But it doesn't matter. It's just a few more clicks.
Click "QT-> launch ".
Linguist "can start QT
Linguist, a localization tool, is also very useful.
References:
How
To: Setup QT 4.5 Visual Studio Integration
In the visual
Install Qt in maxcompute studio 2008
4.5
[Reprinted] compile the QT of
In Windows
Compiling 64-bit Qt in 7 beta x64
4.5.0
Original article link