社区应用 最新帖子 精华区 社区服务 会员列表 统计排行
主题 : 【转载】Qt4.1.1 OpenSource for VC2003, VC2005, BCC的安装
XChinux 离线
级别: 总版主
显示用户信息 
0  发表于: 2006-03-16  

【转载】Qt4.1.1 OpenSource for VC2003, VC2005, BCC的安装

转载自:http://www.qtnode.net/wiki/Qt4_with_Visual_Studio

基本的步骤是:
1、下载Qt 4.1.1 OpenSource for win32
http://www.qtcn.org/download/qt-win-opensource-src-4.1.1.zip
2、下载补丁
http://www.qtcn.org/download/Qtnode-acs-qt4.1.1.zip
3、解压开后,假设把Qt解压到C:\Qt\4.1.1,转到C:\Qt\4.1.1目录:
把上面的补丁也解压到C:\Qt\4.1.1
然后运行补丁installpatch411.bat,然后运行qconfigure msvc2005或者qconfigure msvc.net等依照下面的文章的提示编译安装。

引用

Building Qt
Get and install the Qt source

  1. To start, get the source package: Download Qt (Not the one that comes with mingw, get the zip file)

  2. Unzip your Qt source to a logical location.
    Here are some suggestions:
      C:\Qt\4.1.1\
      C:\Qt\4.1.1-msvc2005\   (<-- if for instance you plan on using Visual Studio 2005)

Get and install the patch that allows Qt to be compiled with Visual Studio compilers

  1. Download Image:Qtnode-acs-qt4.1.1.zip

  2. Unzip the contents of qtnode-acs-qt4.1.1.zip and place all the files in the qt-node-acs-qt4.1.1 directory into the directory you've put the Qt sources.

Open up a command prompt in the Qt source directory

Run cmd.exe however you like, but you must make sure that you have your Visual Studio compiler files in your path.

  * If you are using Microsoft Visual Studio 6.0, try running vcvars32.bat from the command-line.
  * If you are using Microsoft Visual Studio .NET or 2005, go into the program group called 'Visual Studio Tools' and run the command prompt shortcut.


A simple way to ensure your environment is setup properly is to use to see if nmake.exe is in your path:

C:\Qt\4.1.1> nmake /?

Microsoft (R) Program Maintenance Utility Version 8.00.50727.42
Copyright (C) Microsoft Corporation. All rights reserved.

Usage: NMAKE @commandfile
    NMAKE [options] [/f makefile] [/x stderrfile] [macrodefs] [targets]

Options:

....

Once you are sure that you have the Visual Studio compiler in your path and you're at the command prompt in the Qt source directory, you are ready to proceed.
Patching the Qt sources
If you've installed the patch files from qtnode-acs-qt4.1.1.zip correctly then you should be able to patch the Qt sources by running:

C:\Qt\4.1.1> installpatch411.bat

You should see a lot of action, which is normal, which shows you all the files being patched:

C:\Qt\4.1.1> installpatch411.bat
patching file qconfigure.bat
patching file examples/threads/waitconditions/waitconditions.pro
patching file misc/bcc32pch/Makefile.win32-borland
patching file misc/bcc32pch/bcc32pch.cpp
patching file misc/bcc32pch/bcc32pch.pri
patching file misc/bcc32pch/bcc32pch.pro
patching file mkspecs/win32-bccx/qmake.conf

  [snip]

patching file tools/porting/src/rpptreeevaluator.cpp
patching file tools/porting/src/rpptreewalker.cpp
patching file tools/porting/src/src.pro
Press any key to continue . . .
Now run qconfigure.bat

You are now ready for the next step: configuring your Qt install.
Configuring your Qt install (and building qmake)

We will not be using the standard configure.exe that ships with Qt. We will be using qconfigure.bat which was included the qtnode-acs-qt4.1.1.zip file.
But, if you are not sure on which options you want, run configure.exe with the --help option:

configure.exe --help

A list of options will be displayed. Take note of any options you are interested in. Note that by default, static and debug versions of the library are built - this is usually a good thing.

Now that you've written down (or mentally noted) which options you want to use, we will run qconfigure.bat. It will in turn call configure.exe with your chosen options.

qconfigure.bat requires as the first parameter, one of the following compiler choices:

  * msvc   <- if you are using Visual Studio 6.0
  * msvc.net   <- if you are using Visual Studio .NET (2003)
  * msvc2005   <- if you are using Visual Studio 2005


After the first option, you can pass qconfigure.bat any of the configure.exe you had previously noted. For instance you may do something like:

C:\Qt\4.1.1> qconfigure.bat msvc.net -release -no-stl

(This command would produce only the release libraries and would exclude STL support in Qt.)

(Note that if you want to build static libraries instead of shared, see Building static)

You will be prompted 3 times while running qconfigure.bat:

  1. You will be asked to accept the GPL license. Type 'y' followed by <Enter> to continue.
  2. You will then be told that qmake is about to be built. Type 'y' followed by <Enter> to continue. This will take a few moments.
  3. You will then be told that the Makefiles are going to be generated. Type 'y' followed by <Enter> to continue. This will be a short operation.

Once qconfigure.bat has completed its work, you will be presented with the following message:

====================================================

You are now ready to build Qt (msvc2005)

If you specified -static, type 'nmake sub-src'
          otherwise, type 'nmake'

To start over, type 'nmake distclean'
and then re-run qconfigure.bat

====================================================

Building the Qt library
After configuration and building qmake, you are now ready to build the library. Simply run nmake:

C:\Qt\4.1.1> nmake

Qt takes a long time to compile. Now's a good time to brew a pot of coffee.

(If you've specified -static as one of your configuration options, see Building static)
Setting up your environment

There are multiple approaches to this, but this is a foolproof way to ensure that your newly create Qt libs are usable.

Prepend the Qt bin directory to your PATH. Depending on where you installed your Qt sources, it may be something like:

  * C:\Qt\4.1.1\bin
  * C:\Qt\4.1.1-msvc2005\bin
  * C:\Qt\4.1.1-visual-studio\bin

Ensure that the QMAKESPEC environment variable is set to the appropriate value.

  * If you use Visual Studio 6.0, then win32-msvc would be the correct value.
  * If you use Visual Studio .NET (2003), then win32-msvc.net would be the correct value.
  * If you use Visual Studio 2005, then win32-msvc2005 would be the correct value.

(Note: this is the recommended practice from qtnode. You can use Qt in other ways with different settings, but this way is foolproof.)

To set your environment variables in Windows, please see http://www.cs.usask.ca/grads/wew036/latex/env.html

Note that you may have to re-open a command window before your settings are changed.
To check that your PATH is set correctly:

C:\> qmake -v
QMake version: 2.00a
Using Qt version 4.1.1 in C:\Qt\4.1.1\lib

To see if QMAKESPEC is set correctly:

C:\> echo %QMAKESPEC%
win32-msvc2005

Testing your install

Please test your install from the command-line first. Follow the Hello World instructions.
Creating Visual Studio projects

{Note: the following works with MS Visual Studio 2005, not tested on other versions - look for an expanded section of this section later}


To create a project, use the -t and -o options.

Normally, (as in the Hello World example), you would simply type:

prompt> qmake -project
prompt> qmake

To create a .vcproj which will be used by Visual Studio, we will type:

prompt> qmake -project -t vcapp -o projectname
prompt> qmake

Where projectname would be whatever you like the file to be made. If we ran the command above as written in a directory with some sources, we would end up with a file named:

  projectname.vcproj

You can then double-click on this vcproj file or simply type its name in the command window and Visual Studio will create an associated .sln file.

The -t option was used to specify the template used by qmake. By default, the template is app. The app template creates Makefiles which can be used on the command-line when running nmake. But since we are interest in using the Visual Studio IDE, we will want a vcapp which will give us a .vcproj instead of the regular Makefiles.

  Note that you could also use the -tp vc option instead of -t vcapp. This will prepend vc to the default template (which is normally app).

Maintaining Visual Studio Projects

To add files to your project, you can edit your .pro file and re-run qmake. The only problem is that any customizations to your .sln would be lost when you open up the newly updated .vcproj

Is this true? can someone confirm this? Is there a better way to deal with both .pros and .slns?
Additional Info

This set of patches has been altered from the Q../Free project. Original download available at: http://sourceforge.net/project/showfiles.php?group_id=49109

The changes that were made are:

  * the patch file was altered to work with Qt 4.1.1 (patch was originally for 4.1.0)
  * qconfigure.bat was altered so that it:
      o Allows the user to stop the execution before building qmake
      o Allows the user to stop the execution before generating Makefiles
      o Does not automatically call nmake for you. (This is important because if you specified the -static option, you need to be able to run nmake sub-src)
      o added a check for qmake\tmp (when not present this is a problem for some users)

Retrieved from "http://www.qtnode.net/wiki/Qt4_with_Visual_Studio"
[ 此贴被XChinux在2006-03-15 21:00重新编辑 ]
有PHP、Qt、用友相关开发业务相商的朋友请发电子邮件到XChinux@163.com
有技术问题的朋友请在论坛里发贴提问,不要通过私人短信或者QQ/MSN提问讨论,谢谢合作

邮件:  XChinux@163.com
网址: http://www.qtcn.org
博客: http://hi.baidu.com/xchinux
操作系统: 红旗桌面版6, 红旗工作站5, Mandriva 2009
主要开发方向: C++/Qt程序开发、PHP/Apache/MySQL/PostgreSQL程序开发、用友相关二次开发
经常使用的工具: Opera/Firefox, Vim, OpenOffice/RedOffice, 二笔输入法
XChinux 离线
级别: 总版主
显示用户信息 
1  发表于: 2006-03-16  
Re:【转载】Qt4.1.1 OpenSource for VC2003, VC2005,
哪位有兄弟有时间可翻译一下,谢谢。
有PHP、Qt、用友相关开发业务相商的朋友请发电子邮件到XChinux@163.com
有技术问题的朋友请在论坛里发贴提问,不要通过私人短信或者QQ/MSN提问讨论,谢谢合作

邮件:  XChinux@163.com
网址: http://www.qtcn.org
博客: http://hi.baidu.com/xchinux
操作系统: 红旗桌面版6, 红旗工作站5, Mandriva 2009
主要开发方向: C++/Qt程序开发、PHP/Apache/MySQL/PostgreSQL程序开发、用友相关二次开发
经常使用的工具: Opera/Firefox, Vim, OpenOffice/RedOffice, 二笔输入法
tonylk 离线
级别: 新手上路
显示用户信息 
2  发表于: 2006-03-16  
Re:【转载】Qt4.1.1 OpenSource for VC2003, VC2005,
Qtnode-acs-qt4.1.1.zip这个patch和qt-win的patch是同一个吗?qt-win的安装好像没那么麻烦吧。。
XChinux 离线
级别: 总版主
显示用户信息 
3  发表于: 2006-03-16  
Re:【转载】Qt4.1.1 OpenSource for VC2003, VC2005,
这个我不太清楚。qt-win那个我没装过。
这个同时支持vc2003, vc2005和borland bcc
有PHP、Qt、用友相关开发业务相商的朋友请发电子邮件到XChinux@163.com
有技术问题的朋友请在论坛里发贴提问,不要通过私人短信或者QQ/MSN提问讨论,谢谢合作

邮件:  XChinux@163.com
网址: http://www.qtcn.org
博客: http://hi.baidu.com/xchinux
操作系统: 红旗桌面版6, 红旗工作站5, Mandriva 2009
主要开发方向: C++/Qt程序开发、PHP/Apache/MySQL/PostgreSQL程序开发、用友相关二次开发
经常使用的工具: Opera/Firefox, Vim, OpenOffice/RedOffice, 二笔输入法
tonylk 离线
级别: 新手上路
显示用户信息 
4  发表于: 2006-03-17  
Re:【转载】Qt4.1.1 OpenSource for VC2003, VC2005,
楼主真勤劳,恢复好快啊。。
其实我使用的是VC6,等下完了试一下能不能编译。
lwm668 离线
级别: 新手上路
显示用户信息 
5  发表于: 2006-03-20  
编译能过,但我想用VC2005写一个简单的程序,编译能通过,但链接时要出错,我把相关的配置(如:include等文件夹都加了),但还是链接出错
lwm668 离线
级别: 新手上路
显示用户信息 
6  发表于: 2006-03-27  
对了,凡是有Q_OBJECT的cpp或h文件都回链接错
阿威 离线
级别: 新手上路
显示用户信息 
7  发表于: 2006-05-07  
是不是打了补丁就可以使用MinGW以外的方式编译了???
smallpig 离线
级别: 新手上路
显示用户信息 
8  发表于: 2006-05-11  
这个编译出来的qmake文件生成的vcproj文件好像有问题,rcc的项目有问题。而且生成的dll,在程序运行时对cpu时钟的占用始终100%。
zhaoxiuyan09 离线
级别: 新手上路
显示用户信息 
9  发表于: 2009-05-08  
现在我用的是Qt4.5.1支持VC2005么?
天行健,君子以自强不息!
描述
快速回复

认证码:

验证问题:
90 * 2 = ? 正确答案:180
按"Ctrl+Enter"直接提交