In this article, I'll explain how to build Qt 4.8 in Windows by VS 2005. I take Qt 4.8.6 as the building target.
Step 0, Download the Qt 4.8.6, and uncompress the package. For me, the source code of Qt was in C:\Lib\Qt\qt-everywhere-opensource-src-4.8.6.
Step 1 (skipable): Modify the file, qt-everywhere-opensource-src-4.8.6\mkspecs\win32-msvc2005, line 23:
qmake_cflags_release =-o2-mdqmake_cflags_release_with_debuginfo + =-o2-md-ziqmake_ Cflags_debug =-zi-mdd
To
qmake_cflags_release =-o2-mtqmake_cflags_release_with_debuginfo + =-o2-mt-ziqmake_ Cflags_debug =-zi-mtd
Step 2:modify The file, Qt-everywhere-opensource-src-4.8.6\src\gui\kernel\qclipboard_win.cpp, line 304:
Static BOOL isprocessbeingdebugged(HWND hwnd) {DWORD PID= 0;if(!GetWindowThreadProcessId (hwnd,&pid|| !pidreturn false;ConstHANDLE ProcessHandle=OpenProcess (Process_query_information, FALSE, PID);if(!ProcessHandle)return false; BOOL debugged=FALSE; Checkremotedebuggerpresent (ProcessHandle,&debugged); CloseHandle (ProcessHandle);returnDebugged!=FALSE;}
To IS
Static BOOL isprocessbeingdebugged(HWND hwnd) {#if defined (_msc_ver) && _msc_ver <= 1400 return false;#elseDWORD PID= 0;if(!GetWindowThreadProcessId (hwnd,&pid|| !pidreturn false;ConstHANDLE ProcessHandle=OpenProcess (Process_query_information, FALSE, PID);if(!ProcessHandle)return false; BOOL debugged=FALSE; Checkremotedebuggerpresent (ProcessHandle,&debugged); CloseHandle (ProcessHandle);returnDebugged!=FALSE;#endif}
Step 3:modify the file, qt-everywhere-opensource-src-4.8.6\src\3rdparty\webkit\source\webcore\platform\ DefaultLocalizationStrategy.cpp, line 237:
String Defaultlocalizationstrategy::Contextmenuitemtaglookupindictionary (ConstString&selectedstring) {#if defined (building_on_leopard) | | defined (BUILDING_ON_SNOW_LEOPARD)Unused_param (selectedstring);return web_ui_string("Look up in Dictionary","Look up in Dictionary context menu item");#else#if Use (CF)Retainptr<Cfstringref>Selectedcfstring (ADOPTCF, Truncatedstringforlookupmenuitem (selectedstring). createcfstring ());return formatlocalizedstring(Web_ui_string ("Look Up"%@ "","Look up context menu item with selected word"), Selectedcfstring.get ());#else return web_ui_string("Look Up" <selection> "" ","Look up context menu item with selected word"). Replace ("<selection>", Truncatedstringforlookupmenuitem (selectedstring));#endif#endif}
To IS
String Defaultlocalizationstrategy::Contextmenuitemtaglookupindictionary (ConstString&selectedstring) {#if defined (building_on_leopard) | | defined (BUILDING_ON_SNOW_LEOPARD)Unused_param (selectedstring);return web_ui_string("Look up in Dictionary","Look up in Dictionary context menu item");#else#if Use (CF)Retainptr<Cfstringref>Selectedcfstring (ADOPTCF, Truncatedstringforlookupmenuitem (selectedstring). createcfstring ());return formatlocalizedstring(Web_ui_string ("Look Up"%@ "","Look up context menu item with selected word"), Selectedcfstring.get ());#else#if (0) return web_ui_string("Look Up" <selection> "" ","Look up context menu item with selected word"). Replace ("<selection>", Truncatedstringforlookupmenuitem (selectedstring));#else return web_ui_string("Look up <selection>","Look up context menu item with selected word"). Replace ("<selection>", Truncatedstringforlookupmenuitem (selectedstring));#endif#endif#endif}
4. Create a folder, which'll contain the built binaries, for me, it is C:\Lib\Qt\qt-everywhere-opensource-src-4.8.6\buil T. Copy the Qt-everywhere-opensource-src-4.8.6\mkspecs folder into this folder.
5. Open a VS2005 command line prompt to the configuration Qt.
THe configure arguments, for me, I use
Configuration-platform Win32-msvc2005-shared-debug-and-release-nomake Demos-nomake examples-fast-mp-opensource-st L-prefix C:\Lib\Qt\qt-everywhere-opensource-src-4.8.6\built
Press ENTER key then Y and then the NMAKE file would is generated.
6. After the gernerating have been done, type "nmake" and press ENTER, wait for the binaries has been generated. The building of code cast long time, which depends on how to much money to put in your computer.
7. Type Namke install, to organize the built folder. do notCopy "include" folder in the QT source root, which is depends on source code heavily. But the target folder (where it is built folder) is portable, and you should use this in your working folder.
Build Qt 4.8 in Windows by VS2005