• 26789阅读
  • 17回复

在Visual Studio 2008中安装Qt 4.5 [复制链接]

上一主题 下一主题
离线agassi_p
 
只看楼主 倒序阅读 楼主  发表于: 2009-03-24
1,确保正确安装Visual Studio 2008。

注意:最初我在编译qt总有提示:没有包含:"windows.h",然后就无法进行configure。最后我卸载了vs2008重新安装了默认版本,在编译还是同样错误;再次卸载vs2008重新安装了完全版本,在后面编译时就没有错误了。

2,下载Qt4.5源代码

版本随时在更新。http://www.qtsoftware.com/downloads

选择LGPL/Free Downloads,然后选择download qt sdk for windows(就选完整的sdk吧,有完整的资料,对我们初学者很有用)。

3,解压Qt4.5代码

这是我的目录:E:\Qt\4.5SDK;(下一级目录是E:\Qt\4.5SDK\qt):

(E盘的格式是fat32,听说ntfs有点影响)


4,编译Qt4.5源代码

通过"开始"菜单 -> "Microsoft Visual Studio 2008" -> "Visual Studio Tools", 运行vs2008命令行提示。

C:\Program Files\Microsoft Visual Studio 9.0\VC> cd c:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools>
C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools> vsvars32.bat
C:\Program Files\Microsoft Visual Studio 9.0Common7\Tools> e:
E:\> cd e:\qt\4.5sdk\qt
E:\Qt\4.5SDK\qt> configure -debug-and-release -static
E:\Qt\4.5SDK\qt> nmake

注意:configure 大概用一小时。namke从十点多开始,直到一点我睡觉还没有编译完,第二天大早已完成,所以估计用了三小时以上。传说编译时间和电脑配置有很大关系。。貌似电脑老了。另外,nmake以后,还是有一些警告错误,我没有理会。

5,配置环境变量

在"我的电脑"上单击右键,进入"属性",然后打开"环境变量"对话框.
在PATH环境变量中添加:"E:\Qt\4.5sdk\qt\bin".
打开VS2008,将Qt路径添加到VC编译环境中,工具->选项->项目和解决方案->VC++目录,在包含文件一栏添加: E:\Qt\4.5sdk\qt\include\QtGui;E:\Qt\4.5sdk\qt\include\QtCore;E:\Qt\4.5sdk\qt\include,在库文件一栏添加E:\Qt\4.5sdk\qt\lib;

到这里,我很高兴的重启VS2008,以为能使用了,结果。。。。无法新建qt项目,继续往下看吧。。

6,安装一个集成软件

下载Trolltech Qt Visual Studio Integration v1.40或之后的版本,用关键字 “Qt Visual Studio Integration”搜一下就行。

我的是:http://3ddown.com/soft/33062.htm

把v1.40和它对应的v1.40 注册文件(Keygen)同时下载,然后按提示装上就大功告成!写一个测试程序试试吧。。


参考资料:

http://blog.csdn.net/cxjnet/archive/2009/03/08/3968317.aspx

http://hi.baidu.com/wenjiejia/blog/item/c017bb1b9ddd1e1e8618bffe.html

http://www.cnblogs.com/lansh/archive/2007/11/29/952783.html

此文同时写在:http://hi.baidu.com/agassi_p/blog/item/455833601e4eb14ceaf8f866.html
[ 此帖被agassi_p在2009-04-01 22:19重新编辑 ]
离线chencongsytu

只看该作者 1楼 发表于: 2009-03-25
6 集成环境,最新的不是免费了么?
离线sodwell

只看该作者 2楼 发表于: 2009-03-25
晕 还是用的盗版的啊 ..................
离线agassi_p
只看该作者 3楼 发表于: 2009-03-25
引用第1楼chencongsytu于2009-03-25 08:40发表的  :
6 集成环境,最新的不是免费了么?

最新的晓不得是多少,我下载这个也很方便使用哈!
离线洞里的火
只看该作者 4楼 发表于: 2009-03-26
为什么要“新建Qt项目”?
学一下qmake就那么困难么?
qmake -t vcapp直接输出建好的vcproj文件,还用什么Intergration?
离线muwanqing
只看该作者 5楼 发表于: 2009-03-30
我静态编译的时候  总是出错  不过没有LZ的这两步

C:\Program Files\Microsoft Visual Studio 9.0\VC> cd c:\Program Files\Microsoft Visual Studio 8\Common7\Tools>
C:\Program Files\Microsoft Visual Studio 8\Common7\Tools> vsvars32.bat

谁解释一下   vsvars32.bat  是干什么用的?
离线gongchangxin

只看该作者 6楼 发表于: 2009-04-01
我在编译4.5时出错,哪为高人给看看。

copy qmake.exe C:\Qt\2009.01\qt\bin\qmake.exe
1 file(s) copied.
Creating makefiles in src...
Generating Makefiles...
Could not find mkspecs for your QMAKESPEC(win32-g++) after trying:
C:/qt-greenhouse/Trolltech/Code_less_create_more/Trolltech/Code_less_cre
ate_more/Troll/4.5.0/qt\mkspecs
Error processing project file: C:/Qt/2009.01/qt/projects.pro
Qmake failed, return code 3
离线agassi_p
只看该作者 7楼 发表于: 2009-04-01
引用第5楼muwanqing于2009-03-30 12:05发表的  :
我静态编译的时候  总是出错  不过没有LZ的这两步
C:Program FilesMicrosoft Visual Studio 9.0VC> cd c:Program FilesMicrosoft Visual Studio 8Common7Tools>
C:Program FilesMicrosoft Visual Studio 8Common7Tools> vsvars32.bat
.......

应该是设置vs的一些库文件,为qt编译安装配置环境。
离线muwanqing
只看该作者 8楼 发表于: 2009-04-02
vs2008 sp1 下    nmake时出错   楼主用的是不是SP1

只是静态编译事出错  
[ 此帖被muwanqing在2009-04-02 16:37重新编辑 ]
离线lxingbo
只看该作者 9楼 发表于: 2009-04-04
试试先在qt/qmake目录下执行make clean, 然后再configure
引用第6楼gongchangxin于2009-04-01 10:51发表的  :
我在编译4.5时出错,哪为高人给看看。
copy qmake.exe C:Qt2009.01qtbinqmake.exe
1 file(s) copied.
Creating makefiles in src...
.......
离线touch
只看该作者 10楼 发表于: 2009-04-10
有VS2005的吗?
离线aq_1000

只看该作者 11楼 发表于: 2009-04-12
我编译QT库的时候,编译出了20多G,怎么回事啊?
执行了nmake -clean后还有7G多
离线daizb05
只看该作者 12楼 发表于: 2009-05-11
引用楼主agassi_p于2009-03-24 23:14发表的 在Visual Studio 2008中安装Qt 4.5 :
1,确保正确安装Visual Studio 2008。
注意:最初我在编译qt总有提示:没有包含:"windows.h",然后就无法进行configure。最后我卸载了vs2008重新安装了默认版本,在编译还是同样错误;再次卸载vs2008重新安装了完全版本,在后面编译时就没有错误了。
2,下载Qt4.5源代码
.......

为什么我的安装需要license,你们的安装时什么样的
离线zsq4ever
只看该作者 13楼 发表于: 2009-05-12
谢谢了,学习了
离线bygreen

只看该作者 14楼 发表于: 2009-05-24
QT4.5 在visual studio 2008根本没办法正确编译static版的工程啊,不知道楼主的是怎么编译过的,我编译了N遍了,在编译Webkit和Design时都出现Link错误,shared版没有问题。
离线agassi_p
只看该作者 15楼 发表于: 2009-05-27
引用第11楼aq_1000于2009-04-12 14:59发表的  :
我编译QT库的时候,编译出了20多G,怎么回事啊?
执行了nmake -clean后还有7G多


E:\Qt\4.5SDK\qt> configure -debug-and-release -static

你在配置的时候,要根据需求来配置,静态编译两个版本肯定很大。去掉 -static编译就没有这么多,不过这样的话,有些功能就用不起了。
离线agassi_p
只看该作者 16楼 发表于: 2009-05-27
引用第14楼bygreen于2009-05-24 21:52发表的  :
QT4.5 在visual studio 2008根本没办法正确编译static版的工程啊,不知道楼主的是怎么编译过的,我编译了N遍了,在编译Webkit和Design时都出现Link错误,shared版没有问题。


是有些错误,我那个也提示了webkit的link错误。
不过,你在nmake 后面加个-s 还是-k(具体是-s还是-k我忘记了,你可以nmake -help查查看)就可以忽略这些错误而不终止编译,最终得到最后编译好的文件。
离线eclipseluo

只看该作者 17楼 发表于: 2010-08-14
Configuration:
    minimal-config
    small-config
    medium-config
    large-config
    full-config
    build_all
    debug
Qt Configuration:
    release
    debug
    zlib
    png
    accessibility
    qt3support
    opengl
    s60
    ipv6
    script
    scripttools
    xmlpatterns
    multimedia
    audio-backend
    webkit
    native-gestures
    svg
    minimal-config
    small-config
    medium-config
    large-config
    full-config

QMAKESPEC...................win32-msvc2008 (detected)
Architecture................windows
Maketool....................nmake
Debug symbols...............yes
Link Time Code Generation...no
Accessibility support.......yes
STL support.................yes
Exception support...........yes
RTTI support................yes
MMX support.................yes
3DNOW support...............yes
SSE support.................yes
SSE2 support................yes
IWMMXT support..............no
OpenGL support..............yes
OpenVG support..............no
OpenSSL support.............no
QtDBus support..............no
QtXmlPatterns support.......yes
Phonon support..............no
QtMultimedia support........yes
WebKit support..............yes
Declarative support.........no
QtScript support............yes
QtScriptTools support.......yes
Graphics System.............raster
Qt3 compatibility...........yes

Third Party Libraries:
    ZLIB support............qt
    GIF support.............plugin
    TIFF support............plugin
    JPEG support............plugin
    PNG support.............qt
    MNG support.............plugin
    FreeType support........no

Styles:
    Windows.................yes
    Windows XP..............no
    Windows Vista...........no
    Plastique...............yes
    Cleanlooks..............yes
    Motif...................yes
    CDE.....................yes
    Windows CE..............no
    Windows Mobile..........no
    S60.....................no

Sql Drivers:
    ODBC....................no
    MySQL...................no
    OCI.....................no
    PostgreSQL..............no
    TDS.....................no
    DB2.....................no
    SQLite..................plugin (qt)
    SQLite2.................no
    InterBase...............no

Sources are in..............D:\QT4.6.3
Build is done in............D:\QT4.6.3
Install prefix..............D:\QT4.6.3
Headers installed to........D:\QT4.6.3\include
Libraries installed to......D:\QT4.6.3\lib
Plugins installed to........D:\QT4.6.3\plugins
Binaries installed to.......D:\QT4.6.3\bin
Docs installed to...........D:\QT4.6.3\doc
Data installed to...........D:\QT4.6.3
Translations installed to...D:\QT4.6.3\translations
Examples installed to.......D:\QT4.6.3\examples
Demos installed to..........D:\QT4.6.3\demos

Creating qmake...

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

        cl -c -Foproject.obj  -W3 -nologo -O2  -I. -Igenerators -Igenerators\uni
x -Igenerators\win32 -Igenerators\mac -Igenerators\symbian  -ID:\QT4.6.3\include
-ID:\QT4.6.3\include\QtCore  -ID:\QT4.6.3\include -ID:\QT4.6.3\include\QtCore
-ID:\QT4.6.3\src\corelib\global  -ID:\QT4.6.3\src\corelib\xml  -ID:\QT4.6.3\mksp
ecs\win32-msvc2008   -ID:\QT4.6.3\tools\shared  -DQT_NO_TEXTCODEC -DQT_NO_UNICOD
ETABLES -DQT_LITE_COMPONENT -DQT_NODLL -DQT_NO_STL  -DQT_NO_COMPRESS -DUNICODE -
DHAVE_QCONFIG_CPP -DQT_BUILD_QMAKE -DQT_NO_THREAD  -DQT_NO_QOBJECT -DQT_NO_GEOM_
VARIANT -DQT_NO_DATASTREAM -DQT_NO_PCRE -DQT_BOOTSTRAPPED   -DQMAKE_OPENSOURCE_E
DITION project.cpp
project.cpp
project.cpp(60) : fatal error C1083: Cannot open include file: 'windows.h': No s
uch file or directory
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN
\cl.EXE"' : return code '0x2'
Stop.

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

        del qbitarray.obj
找不到 D:\QT4.6.3\qmake\qbitarray.obj
        del qbuffer.obj
找不到 D:\QT4.6.3\qmake\qbuffer.obj
        del qcryptographichash.obj
找不到 D:\QT4.6.3\qmake\qcryptographichash.obj
        del qlinkedlist.obj
找不到 D:\QT4.6.3\qmake\qlinkedlist.obj
        del qfsfileengine.obj
找不到 D:\QT4.6.3\qmake\qfsfileengine.obj
        del qfsfileengine_iterator.obj
找不到 D:\QT4.6.3\qmake\qfsfileengine_iterator.obj
        del qbytearray.obj
找不到 D:\QT4.6.3\qmake\qbytearray.obj
        del qvsnprintf.obj
找不到 D:\QT4.6.3\qmake\qvsnprintf.obj
        del qbytearraymatcher.obj
找不到 D:\QT4.6.3\qmake\qbytearraymatcher.obj
        del qdatetime.obj
找不到 D:\QT4.6.3\qmake\qdatetime.obj
        del qdir.obj
找不到 D:\QT4.6.3\qmake\qdir.obj
        del qdiriterator.obj
找不到 D:\QT4.6.3\qmake\qdiriterator.obj
        del qfile.obj
找不到 D:\QT4.6.3\qmake\qfile.obj
        del qtemporaryfile.obj
找不到 D:\QT4.6.3\qmake\qtemporaryfile.obj
        del qabstractfileengine.obj
找不到 D:\QT4.6.3\qmake\qabstractfileengine.obj
        del qfsfileengine_win.obj
找不到 D:\QT4.6.3\qmake\qfsfileengine_win.obj
        del qfsfileengine_iterator_win.obj
找不到 D:\QT4.6.3\qmake\qfsfileengine_iterator_win.obj
        del qfileinfo.obj
找不到 D:\QT4.6.3\qmake\qfileinfo.obj
        del qglobal.obj
找不到 D:\QT4.6.3\qmake\qglobal.obj
        del qhash.obj
找不到 D:\QT4.6.3\qmake\qhash.obj
        del qiodevice.obj
找不到 D:\QT4.6.3\qmake\qiodevice.obj
        del qlist.obj
找不到 D:\QT4.6.3\qmake\qlist.obj
        del qlocale.obj
找不到 D:\QT4.6.3\qmake\qlocale.obj
        del qmalloc.obj
找不到 D:\QT4.6.3\qmake\qmalloc.obj
        del qmap.obj
找不到 D:\QT4.6.3\qmake\qmap.obj
        del qregexp.obj
找不到 D:\QT4.6.3\qmake\qregexp.obj
        del qtextcodec.obj
找不到 D:\QT4.6.3\qmake\qtextcodec.obj
        del qutfcodec.obj
找不到 D:\QT4.6.3\qmake\qutfcodec.obj
        del qstring.obj
找不到 D:\QT4.6.3\qmake\qstring.obj
        del qstringlist.obj
找不到 D:\QT4.6.3\qmake\qstringlist.obj
        del qtextstream.obj
找不到 D:\QT4.6.3\qmake\qtextstream.obj
        del qdatastream.obj
找不到 D:\QT4.6.3\qmake\qdatastream.obj
        del quuid.obj
找不到 D:\QT4.6.3\qmake\quuid.obj
        del qvector.obj
找不到 D:\QT4.6.3\qmake\qvector.obj
        del qsettings.obj
找不到 D:\QT4.6.3\qmake\qsettings.obj
        del qlibraryinfo.obj
找不到 D:\QT4.6.3\qmake\qlibraryinfo.obj
        del qvariant.obj
找不到 D:\QT4.6.3\qmake\qvariant.obj
        del qurl.obj
找不到 D:\QT4.6.3\qmake\qurl.obj
        del qsettings_win.obj
找不到 D:\QT4.6.3\qmake\qsettings_win.obj
        del qmetatype.obj
找不到 D:\QT4.6.3\qmake\qmetatype.obj
        del project.obj
找不到 D:\QT4.6.3\qmake\project.obj
        del main.obj
找不到 D:\QT4.6.3\qmake\main.obj
        del makefile.obj
找不到 D:\QT4.6.3\qmake\makefile.obj
        del unixmake.obj
找不到 D:\QT4.6.3\qmake\unixmake.obj
        del unixmake2.obj
找不到 D:\QT4.6.3\qmake\unixmake2.obj
        del mingw_make.obj
找不到 D:\QT4.6.3\qmake\mingw_make.obj
        del option.obj
找不到 D:\QT4.6.3\qmake\option.obj
        del winmakefile.obj
找不到 D:\QT4.6.3\qmake\winmakefile.obj
        del projectgenerator.obj
找不到 D:\QT4.6.3\qmake\projectgenerator.obj
        del property.obj
找不到 D:\QT4.6.3\qmake\property.obj
        del meta.obj
找不到 D:\QT4.6.3\qmake\meta.obj
        del makefiledeps.obj
找不到 D:\QT4.6.3\qmake\makefiledeps.obj
        del metamakefile.obj
找不到 D:\QT4.6.3\qmake\metamakefile.obj
        del xmloutput.obj
找不到 D:\QT4.6.3\qmake\xmloutput.obj
        del borland_bmake.obj
找不到 D:\QT4.6.3\qmake\borland_bmake.obj
        del msvc_nmake.obj
找不到 D:\QT4.6.3\qmake\msvc_nmake.obj
        del msvc_dsp.obj
找不到 D:\QT4.6.3\qmake\msvc_dsp.obj
        del msvc_vcproj.obj
找不到 D:\QT4.6.3\qmake\msvc_vcproj.obj
        del msvc_objectmodel.obj
找不到 D:\QT4.6.3\qmake\msvc_objectmodel.obj
        del symmake.obj
找不到 D:\QT4.6.3\qmake\symmake.obj
        del symmake_abld.obj
找不到 D:\QT4.6.3\qmake\symmake_abld.obj
        del symmake_sbsv2.obj
找不到 D:\QT4.6.3\qmake\symmake_sbsv2.obj
        del initprojectdeploy_symbian.obj
找不到 D:\QT4.6.3\qmake\initprojectdeploy_symbian.obj
        del registry.obj
找不到 D:\QT4.6.3\qmake\registry.obj
        del epocroot.obj
找不到 D:\QT4.6.3\qmake\epocroot.obj
        del pbuilder_pbx.obj
找不到 D:\QT4.6.3\qmake\pbuilder_pbx.obj
        del qxmlstream.obj
找不到 D:\QT4.6.3\qmake\qxmlstream.obj
        del qxmlutils.obj
找不到 D:\QT4.6.3\qmake\qxmlutils.obj
        del qnumeric.obj
找不到 D:\QT4.6.3\qmake\qnumeric.obj
        del vc60.pdb
找不到 D:\QT4.6.3\qmake\vc60.pdb
        del vc70.pdb
找不到 D:\QT4.6.3\qmake\vc70.pdb
        del qmake.pdb
找不到 D:\QT4.6.3\qmake\qmake.pdb
        del qmake.ilk
找不到 D:\QT4.6.3\qmake\qmake.ilk
        del qmake.tds
找不到 D:\QT4.6.3\qmake\qmake.tds

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

        cl -c -Foproject.obj  -W3 -nologo -O2  -I. -Igenerators -Igenerators\uni
x -Igenerators\win32 -Igenerators\mac -Igenerators\symbian  -ID:\QT4.6.3\include
-ID:\QT4.6.3\include\QtCore  -ID:\QT4.6.3\include -ID:\QT4.6.3\include\QtCore
-ID:\QT4.6.3\src\corelib\global  -ID:\QT4.6.3\src\corelib\xml  -ID:\QT4.6.3\mksp
ecs\win32-msvc2008   -ID:\QT4.6.3\tools\shared  -DQT_NO_TEXTCODEC -DQT_NO_UNICOD
ETABLES -DQT_LITE_COMPONENT -DQT_NODLL -DQT_NO_STL  -DQT_NO_COMPRESS -DUNICODE -
DHAVE_QCONFIG_CPP -DQT_BUILD_QMAKE -DQT_NO_THREAD  -DQT_NO_QOBJECT -DQT_NO_GEOM_
VARIANT -DQT_NO_DATASTREAM -DQT_NO_PCRE -DQT_BOOTSTRAPPED   -DQMAKE_OPENSOURCE_E
DITION project.cpp
project.cpp
project.cpp(60) : fatal error C1083: Cannot open include file: 'windows.h': No s
uch file or directory
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN
\cl.EXE"' : return code '0x2'
Stop.
Building qmake failed, return code 2


报这个错误时什么意思啊??
快速回复
限100 字节
 
上一个 下一个