首页 > Windows开发 > 详细

Build Qt 4.8 in windows by VS2005

时间:2015-04-10 07:05:09      阅读:477      评论:0      收藏:0      [点我收藏+]

In this article, I will 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 is 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 -MD
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MD -Zi
QMAKE_CFLAGS_DEBUG      = -Zi -MDd



to
QMAKE_CFLAGS_RELEASE    = -O2 -MT
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MT -Zi
QMAKE_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) || !pid)
        return false;
    const HANDLE processHandle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
    if (!processHandle)
       return false;
    BOOL debugged = FALSE;
    CheckRemoteDebuggerPresent(processHandle, &debugged);
    CloseHandle(processHandle);
    return debugged != FALSE;
}

To be

static bool isProcessBeingDebugged(HWND hwnd)
{
#if defined(_MSC_VER) && _MSC_VER <= 1400 
    return false;
#else
    DWORD pid = 0;
    if (!GetWindowThreadProcessId(hwnd, &pid) || !pid)
        return false;
    const HANDLE processHandle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
    if (!processHandle)
       return false;
    BOOL debugged = FALSE;
    CheckRemoteDebuggerPresent(processHandle, &debugged);
    CloseHandle(processHandle);
    return debugged != 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(const String& 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 be

String DefaultLocalizationStrategy::contextMenuItemTagLookUpInDictionary(const String& 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 will contain the built binaries, for me, it be C:\Lib\Qt\qt-everywhere-opensource-src-4.8.6\built. Copy the qt-everywhere-opensource-src-4.8.6\mkspecs folder into this folder.


5. open a VS2005 command line prompt to configuration Qt.

技术分享


The configure arguments, for me , I use

configuration -platform win32-msvc2005 -shared -debug-and-release -nomake demos -nomake examples -fast -mp -opensource -stl -prefix C:\Lib\Qt\qt-everywhere-opensource-src-4.8.6\built

Press enter key then y, then the nmake file would be generated.


6. After the gernerating has been done, type "nmake" and press enter, wait the binaries has been generated.The building of code cast long time, which depends on how much money you put in your computer.



7. type namke install, to organize the built folder. DO NOT copy "include "folder in the qt source root, that depends on source code heavily. But the target folder(in here it is built folder) is portable, you should use this in your working folder.

Build Qt 4.8 in windows by VS2005

原文:http://blog.csdn.net/u013606170/article/details/44971791

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!