环境搭建目标: 在winxp下的codeblocks里面编辑QT的应用程序,并在codeblocks里直接build.run搭建一个集成开发环境。
第一步安装
安装qt-win-opensource-4.7.4-vs2008;qt-vs-addin-1.1.9 plugin; codeblocks;
把QT安装在codeblocks目录下
第二步codeblocks qmake的集成
在codeblocks的menu/tool下面加上加入2个tool 一个是Qmake_project, 一个是Qmake如下图
第三步编写源程序
建立工程属性中加上project parser的一些头文件,并在editor中设置enable headers code-completion,编写相应的程序
project build options把$make -f $makefile $target去掉$target
设置project属性为This is a custom Makefile;Output filename中,bin/debug/projectname.exe改成debug/projectname.exe, 设置相应的编译器为vs2010
写源文件后,点tool/Qmake_project生成 pro文件, 点tool/Qmake生成....Makefile Makefile.debug等;
第四步 编译
调用相应的编译器调用makefile了,有3种方法:
法1可以调用vs2008编译运行,因为集成QT了
法2安装vs2010,设置环境变量
设在Code::Blocks内不起作用,设在环境变量里面;或者每次在makefile里面设置
PATH: C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE;C:\Program Files\Microsoft Visual Studio 10.0\VC\bin;C:\Program Files\IDM Computer Solutions\UltraEdit\;C:\MinGW\bin;C:\MinGW\libexec\gcc\mingw32\4.5.2;C:\MinGW\mingw32\bin;C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin;C:\CB_20110815_rev7385_win32\QT\bin (for nmake.exe)
INCLUDE: C:\Program Files\Microsoft Visual Studio 10.0\VC\include;C:\CB_20110815_rev7385_win32\QT\include;C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include;C:\MinGW\include
LIB: C:\Program Files\Microsoft Visual Studio 10.0\VC\lib;C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib;C:\CB_20110815_rev7385_win32\QT\lib;C:\MinGW\lib
直接点build就可以。(要相应)
法3进入Visual Studio 命令提示(2010) 或者运行C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat
输入nmake -f Makefile.debug即可
第五步 运行
点击运行会出现错误“由于应用程序配置不正确,应用程序未能启动”
查看了一下test2.intermediate.manifest文件
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*' />
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32' name='Microsoft.VC90.DebugCRT' version='9.0.21022.8' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
</dependentAssembly>
</dependency>
</assembly>
发现调用的vc9.0的CRT (c run time)正在修复错误中...