編譯QT以前有幾處源碼的編譯的問題必須解決:web
1)、qt的安裝路徑,以及之後使用vs創建qt項目的時候,不能有中文,路徑中也不能有空格.sql
2)、刪除源碼包中bin目錄下的syncqt和syncqt.dat文件,如你不放心可將其更名或剪切到別的位置。如不修改將發生 Perl not found in environment - cannot run syncqt 錯誤。shell
3)、必定要修改\mkspecs\win32-msvc2010下的qmake.conf文件,將其中的"QMAKE_CFLAGS=-nologo -Zm200 -Zc:wchar_t-"改爲"QMAKE_CFLAGS=-nologo -Zm200 -Zc:wchar_t" 注意末尾的」-「號區別。如不修改未來若有項目使用wchar_t,qt卻編譯成wchar_t-,編譯會致使鏈接錯誤,提示找不到Qwstring;ui
4)、關因而否須要修改\mkspecs\win32-msvc2010下的qmake.conf文件中的QMAKE_CFLAGS_RELEASE,QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO,QMAKE_CFLAGS_DEBUG這3處後面的MD,MDd,取決你打算動態仍是靜態編譯,若是是靜態編譯的話,改成:MT,MTd(最後還要在vs2010中的項目屬性中將MD改成MT,以實如今沒有VC庫的電腦也能運行Qt程序。)。若是是動態編譯的話能夠不改。debug
5)、必定要修改src\3rdparty\webkit\Source\WebCore\platform下的DefaultLocalizationStrategy.cpp,定位到327行,將本行替換成return WEB_UI_STRING("Look Up "<selection>"", "Look Up context menu item with selected word").replace("<selection>", truncatedStringForLookupMenuItem(selectedString));(請直接將以上英文部分一次性全複製,其實它們是一行,不要分行復制)。若是你仔細看原來的那行的話,你會發現雙引號是錯誤的,如不修改將出現編譯Webkit 時會出現 U1077錯誤。code
如下是個人編譯腳本,能夠直接使用,保存爲批處理文件在QT解壓後的根目錄運行便可:orm
<!-- lang: shell --> @CALL "C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" @set cur_dir=%cd%\ @set QTDIR=%cur_dir% @set QMAKESPEC=win32-msvc2010 @rem set ConfPara=-debug-and-release -opensource -static -system-sqlite -fast -no-dsp @rem set ConfPara=-debug-and-release -opensource -static -webkit @set ConfPara= -release -platform win32-msvc2010 -webkit -plugin-sql-sqlite -qt-sql-sqlite -opensource -nomake demos -nomake examples @set PATH=C:\Perl;C:\Perl\bin;C:\Perl\site\bin;%QTDIR%/bin;E:\sqlite\bin;%PATH% @set INCLUDE=%MINGWDIR%/include;%QTDIR%/include;%QWTDIR%/src;%LOG4QTDIR%/src;E:\sqlite\include;%INCLUDE% @set LIB=C:\Perl\lib;C:\Perl\site\lib;%MINGWDIR%/lib;%QTDIR%/lib;%QWTDIR%/lib;E:\sqlite\lib;%LIB% @echo *********************************************************************** @echo Created By Sui Libin(gmail:bygreencn.gmail.com) @echo Includes : QT 4.8.二、Visual Studio 2010 @echo QT : %QTDIR% @echo QMAKESPEC: %QMAKESPEC% @echo ConfPara: %ConfPara% @echo *********************************************************************** @type nul>%temp%\~YesOrNoA.tmp @echo. @echo !!!!Build QT? [y/n]? @del /p %temp%\~YesOrNoA.tmp>nul @if not exist %temp%\~YesOrNoA.tmp goto Buildqt @del %temp%\~YesOrNoA.tmp @goto QtEnvironment :Buildqt @type nul>%temp%\~YesOrNo.tmp @echo. @echo !!!!Start to clear project do it? [y/n]? @del /p %temp%\~YesOrNo.tmp>nul @if not exist %temp%\~YesOrNo.tmp goto Cleaning @del %temp%\~YesOrNo.tmp @goto Config :Cleaning @echo Cleaning, please waiting... @nmake clean @nmake confclean :Config @type nul>%temp%\~YesOrNo2.tmp @echo. @echo !!!!Configure project do it? [y/n]? @del /p %temp%\~YesOrNo2.tmp>nul @if not exist %temp%\~YesOrNo2.tmp goto Configuring @del %temp%\~YesOrNo2.tmp @goto Build :Configuring @echo y|configure.exe %ConfPara% @echo Create .vcproj ... @cls @qmake -tp vc -r @ :Build @echo Build it now... @cls @rem jom @nmake @ @rem pause @echo backup pdb file now... @md shared @copy lib shared @copy bin shared @copy *.cache shared :QtEnvironment @echo *********************************************************************** @echo PATH @echo %PATH% @echo *********************************************************************** @echo INCLUDE @echo %INCLUDE% @echo *********************************************************************** @echo LIB @echo %LIB% @echo *********************************************************************** @cmd /k