Qt默認(rèn)使用mingw編譯,不支持VS編譯器,因此,如果需要用VS開(kāi)發(fā),需要將Qt重新編譯。
前提:Qt已安裝(
http://qt.nokia.com/downloads-cn),VS已安裝。
1 下載Visual Studio Add-in
http://qt.nokia.com/downloads-cn2 安裝Visual Studio Add-in
3 重新編譯Qt
a) 用Visual Studio Command Prompt進(jìn)行編譯。
開(kāi)始菜單 --> Microsoft Visual Studio 2008 --> Visual Studio Tools --> Visual Studio Command Prompt。
注意:是使用Visual Studio Command Prompt,而不是直接的cmd Dos窗口。
b) 進(jìn)入Qt的安裝目錄后,執(zhí)行CD Qt,進(jìn)入Qt的根目錄。
cd C:\Qt\2010.05\qt。
c) 運(yùn)行命令 configure -platform win32-msvc2008。o(選擇opensource模式)回車(chē),Y(同意license)回車(chē)
編譯時(shí)間我用了半個(gè)小時(shí)。
d) 運(yùn)行命令nmake。
需要大概3個(gè)小時(shí)。
編譯期間會(huì)產(chǎn)生編譯錯(cuò)誤,我編譯的是Windows 7下的VS2008版本。解決方法如下:
參考:http://tech.it168.com/a2010/1217/1139/000001139431_1.shtml
http://developer.qt.nokia.com/wiki/QtVSAddin (通過(guò)源碼進(jìn)行編譯配置)
http://blog.csdn.net/hongqiang200/archive/2010/09/09/5873585.aspx (編譯錯(cuò)誤解決)
4 配置VS。
打開(kāi)VS2008。Qt --> Options,增加Path:C:\Qt\2010.05\qt。
打開(kāi)pro文件或者新建Qt項(xiàng)目即可。
如果之前是mingw版本,那么在增加path時(shí)可能出現(xiàn):qt in the given path was built using mingw。
解決方法:刪除C:\Qt\2010.05\qt\lib下的libqtmain.a和libqtmaind.a,因?yàn)槭峭ㄟ^(guò)找這2個(gè)文件判斷是否是mingw編譯版本。(可剪切到其他地方,以防再需要回到mingw版本)