一、软件下载及安装
1.QT-SDK for Windows:http://qt.nokia.com/downloads-cn,不想要QT Creator IDE的可从http://qt.nokia.com/downloads-cn中下载qt-win-opensource-4.7.0-mingw.exe
2.MinGW(C++编译器): http://www.mingw.org/ 或http://sourceforge.net/projects/mingw/files/(Qt的安装包中是附带了MinGW的,想要最新版本MinGW的安装
2.1.推荐下载自动安装包安装
2.2.手工安装MinGW:到网站http://sourceforge.net/project/showfiles.php?group_id=2435,下载如下安装包:
binutils-2.17.50-20070129-1.tar.gz
mingw-runtime-3.13.tar.gz
mingw-utils-0.3.tar.gz
mingw32-make-3.81-2.tar.gz
gcc-core-3.4.5-20060117-1.tar.gz
gcc-g++-3.4.5-20060117-1.tar.gz
w32api-3.10.tar.gz
gdb-6.6.tar.tar
2.3.将刚才减压的目录添加到环境变量PATH中,如d:\MinGW,那么添加“d:\MinGW\bin”到系统目录中即可
)
3.Eclipse+CDT:http://www.eclipse.org/cdt/(C/C++开发IDE plugin)
4.Qt Eclipse 集成:http://qt.nokia.com/developer/eclipse-integration(安装时选对Eclipse和MinGW/bin的路径即可)
二、配置
1.配置MinGW环境变量:
MINGW_HOME=C:\Qt\2010.05\mingw
QT=C:\Qt\2010.05\qt
QMAKESPEC=C:\Qt\2010.05\qt\mkspecs\win32-g++
Path=%MINGW_HOME%\bin;%QT%\bin;%MINGW_HOME%\mingw32\bin;%MINGW_HOME%\libexec\gcc\mingw32\4.4.0
LIBRARY_PATH=%MINGW_HOME%\lib;%QT%\lib;%MINGW_HOME%\lib\gcc\mingw32\4.4.0
C_INCLUDE_PATH=%MINGW_HOME%\include;%QT%\include;%MINGW_HOME%\lib\gcc\mingw32\4.4.0\include
CPLUS_INCLUDE_PATH=%MINGW_HOME%\lib\gcc\mingw32\4.4.0\include\c++;%MINGW_HOME%\lib\gcc\mingw32\4.4.0\include\c++\mingw32;%MINGW_HOME%\lib\gcc\mingw32\4.4.0\include\c++\backward;%C_INCLUDE_PATH%
2.为了让CDT能够采用MinGW进行编译,首先Eclipse中将Window->Preferences->C/C++->New CDT project wizard中的toolchains改成MinGW GCC,并设为默认,New CDT Project Wizard->Makefile Project 下Binary parsers把PE Windows parsers与cygwin PE Parser选上.
3.将MinGW目录中(假如没有单独安装Qt的目录下有)的mingw32-make.exe改为make.exe(因为Eclipse预设用来编译的文件为 make.exe 但是 MinGw 安装后 make 的文件名是 mingw32-make.exe因此需要把 mingw32-make 改名为 make!若不想更改,则可以到Window->Preferences->C/C++->New CDT Project Wizard->Makefile Project->Builder Settings中将Build Commond改成mingw32-make),这一步很关键,建立工程时选other,会看到Qt的工程向导,建好,编译,运行。
4. 若出现“Internal Builder: Cannot run program "g++": ?????????¡§?”错误,则可以将CDT插件下的plugins文件夹下的org.eclipse.cdt.core.win32_5.1.0.200909110608.jar解压成文件夹即可,同时把原来jar包删掉.
5.Eclipse中配置QT:
Window—>Preference—>Qt->add
version name:QT2010 bin path:D:\qt\bin Include path:D:\qt\include
注意:
默认的Qt for MinGW的安装,是不安装调试库的,如需运行Debug模式,按照下面的方法编译调试库,
在Qt的bin目录里面,用命令:qtvars.bat compile_debug来编译调试库
如果安装完qt-eclipse-integration-win32-1.6.1.exe,发现第二次启动Eclipse不成功的话,
到Eclipse的plugins目录下,删除文件“com.trolltech.qtcppstartup_1.0.0.jar”即可
http://blog.csdn.net/vagrxie/archive/2009/10/20/4703282.aspx