vs2010如何安装qt插件

Qt默认使用mingw编译,不支持VS编译器,因此,如果需要用VS开发,需要将Qt重新编译。前提:Qt已安装(http://qt.nokia.com/downloads-cn),VS已安装。

1、下载Visual Studio Add-in

  1. http://qt.nokia.com/downloads-cn 

2、安装Visual Studio Add-in

3、重新编译Qt

(1)用Visual Studio Command Prompt进行编译。

开始菜单 --> Microsoft Visual Studio 2008 --> Visual Studio Tools --> Visual Studio Command Prompt。

注意:是使用Visual Studio Command Prompt,而不是直接的cmd Dos窗口。

(2)进入Qt的安装目录后,执行CD Qt,进入Qt的根目录。

  1. cd C:Qt4.8.

(3)运行命令 configure -platform win32-msvc2008。o(选择opensource模式)回车,Y(同意license)回车编译时间我用了半个小时。
   

 

(4)运行命令nmake,需要大概3个小时。

C:Qt4.8.4>nmake

编译期间会产生编译错误,我编译的是Windows 7下的VS2008版本。解决方法如下:

错误:

  1. apiqscriptextensionplugin.h(43): Error: Undefined   
  2. interface  
  3. NMAKE : fatal error U1077: 'C:Qt2010.05qtinmoc.exe' : return   
  4. code '0x1'  
  5. Stop.  
  6. NMAKE : fatal error U1077: '"c:Program FilesMicrosoft   
  7. Visual Studio 9.0VCBIN  
  8. make.exe"' : return code '0x2'  
  9. Stop.  
  10. NMAKE :   
  11. fatal error U1077: 'cd' : return code   
  12. '0x2'  
  13. Stop. 

解决:

删除

  1. C:/Qt/2010.05/qt/src/script/tmp/moc/debug_shared/mocinclude.tmp  
  2. C:/Qt/2010.05/qt/src/script/tmp/moc/release_shared/mocinclude.tmp 

其他错误解决:

删除

  1. C:/Qt/2010.05/qt/src3rdpartywebkitWebCore mpmocdebug_sharedmocinclude.tmp   
  2. C:/Qt/2010.05/qt/src3rdpartywebkitWebCore mpmoc elease_sharedmocinclude.tmp  
  1. 参考:http://tech.it168.com/a2010/1217/1139/000001139431_1.shtml  
  2. http://developer.qt.nokia.com/wiki/QtVSAddin    
  3. (通过源码进行编译配置)  
  4. http://blog.csdn.net/hongqiang200/archive/2010/09/09/5873585.aspx      
  5. (编译错误解决) 

4、配置VS。

配置VS

打开VS2008。Qt --> Options,增加Path:C:Qt2010.05qt。

打开pro文件或者新建Qt项目即可。
  
如果之前是mingw版本,那么在增加path时可能出现:qt in the given path was built using mingw。
  
解决方法:删除C:Qt4.8.4lib下的libqtmain.a和libqtmaind.a,因为是通过找这2个文件判断是否是mingw编译版本。(可剪切到其他地方,以防再需要回到mingw版本)。

原文地址:https://www.cnblogs.com/Yimi/p/7879180.html