Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4588866
  • 博文数量: 671
  • 博客积分: 10010
  • 博客等级: 上将
  • 技术积分: 7310
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-14 09:56
文章分类

全部博文(671)

文章存档

2011年(1)

2010年(2)

2009年(24)

2008年(271)

2007年(319)

2006年(54)

我的朋友

分类: C/C++

2008-06-30 10:27:24

QT4.1.1 with vc++ 6.0

  参考了一些资料,把自己在vc6.0下安装qt的过程和大家一起分享一下.
1 编译QT

  1)下载QT的源代码文件包(注意:必须是.zip后缀的,.exe后缀的包是用mingw做编译器的源代码文件)。

  2)将QT源代码解压到硬盘。

    例如: D:\Qt\4.1.1\或
            D:\Qt\4.1.1-msvc\ 

2 下载并安装允许QT用vc编译的补丁。

  1)从网站 sourceforge.net下载acs-4.1.1-patch.zip 。

  2)将其解压到QT源代码的目录下。

3 打开命令行工具,并把路径切换到QT源代码的目录下。

  运行cmd.exe,然后切换到路径到D:\Program Files\Microsoft Visual Studio\VC98\Bin(VC路径),运行vcvars32.bat ,设置vc6.0编译文件的路径。

  确保环境设置正确的方法是看看nmake.exe是否在路径中:

D:\Qt\4.1> nmake /?

Microsoft (R) Program Maintenance Utility Version 6.00.8168.0

Copyright (C) Microsoft Corp1988-1998.  All rights reserved.

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

Options:

4 给QT源代码打补丁

运行D:\Qt\4.1.1> installpatch411.bat

将会看到下面的一些内容:

D:\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

5 安装QT

  如果不清楚使用什么选项,可以运行configure.exe --help

  然后运行D:\Qt\4.1.1>qconfigure.bat msvc

  开始的时候会提问是否接受GPLlicence,输入y。然后就是漫长的等待了。

在这期间会出现一个错误,fatal error C1083: Cannot open include file: 'uxtheme.h': No such file or directory

提示Uxtheme.h 和Tmschema.h找不到,而Schemadef.h是在Tmschema.h里调用的,所以还需要另外三个文件,这在VC6里面没有,包含在Windows PlatformSDK安转了Visual Studio 2003或 Visual Studio 2005 中都有PlatformSDK。若安装过,就不必费尽去下载385.0 MB的SDK了,默认安装的话三个文件都在
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include
(Uxtheme.h 中定义了在向控件添加外观风格的步骤中以及在相应的代码示例中所引用的 UxTheme API;Tmschema.h 中定义了各个类。

可以到这里下载http://www.cnblogs.com/xcvm/archive/2006/03/08/346013.html

把这三个文件加到vc的include文件夹下,就可以通过编译了。

还有一个错误是NMAKE: fatal error U1077: 'cl.exe' : return code: '0x80' Stop

在网上搜了一下,有人说是内存不足的原因,我也遇到了,重启了一下电脑,只开了一个编译QT的窗口后就什么问题也没有了。

6 设置环境变量

PATH = D:\Qt\4.1.1\bin

QMAKESPEC = win32-msvc

然后重启一下.
检查路径设置的是否正确:

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

C:\> echo %QMAKESPEC%
win32-msvc

至此,QT就安装好了。

下面用一个小程序测试一下

创建文件名为hello.cpp,输入如下代码:

#include
#include

int main(int argc, char **argv) {
  QApplication app(argc, argv);
  QLabel *label = new QLabel("Hello World!");
 
  label->show();

  return app.exec();
}

然后

prompt> qmake -project -o hello.pro

prompt> qmake

prompt> nmake

就会在debug文件夹下生成一个.exe文件。
阅读(4348) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2008-08-03 21:40:10

你好,我按照你介绍的步骤编译qt-win-opensource-src-4.2.3,但是我编译qt自带例子hello.cpp时总出错,出错消息如下: G:\soft\qt\4.2.3\examples\tutorial\t1>qmake -project -o hello.pro G:\soft\qt\4.2.3\examples\tutorial\t1>qmake G:\soft\qt\4.2.3\examples\tutorial\t1>nmake Microsoft (R) Program Maintenance Utility Version 6.00.9782.0 Copyright (C) Microsoft Corp 1988-1998. All rights reserved. NMAKE -f Makefile.Debug all Microsoft (R) Program Maintenance Utility Version 6.00.9782.0 Copyright (C) Microsof