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:\Qt\4.8.

(3)運行命令 configure -platform win32-msvc2008。o(選擇opensource模式)回車,Y(同意license)回車編譯時間我用了半個小時。
   

 

(4)運行命令nmake,需要大概3個小時。

C:\Qt\4.8.4>nmake

 

 

編譯期間會產生編譯錯誤,我編譯的是Windows 7下的VS2008版本。解決方法如下:

錯誤:

  1. api\qscriptextensionplugin.h(43): Error: Undefined   
  2. interface  
  3. NMAKE : fatal error U1077: 'C:\Qt\2010.05\qt\bin\moc.exe' : return   
  4. code '0x1'  
  5. Stop.  
  6. NMAKE : fatal error U1077: '"c:\Program Files\Microsoft   
  7. Visual Studio 9.0\VC\BIN  
  8. \nmake.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/src\3rdparty\webkit\WebCore\tmp\moc\debug_shared\mocinclude.tmp   
  2. C:/Qt/2010.05/qt/src\3rdparty\webkit\WebCore\tmp\moc\release_shared\mocinclude.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:\Qt\2010.05\qt。

打開pro文件或者新建Qt項目即可。
  
如果之前是mingw版本,那么在增加path時可能出現:qt in the given path was built using mingw。
  
解決方法:刪除C:\Qt\4.8.4\lib下的libqtmain.a和libqtmaind.a,因為是通過找這2個文件判斷是否是mingw編譯版本。(可剪切到其他地方,以防再需要回到mingw版本)。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM