Build Qt 4.8 in windows by VS2005

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 theQt 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.

时间: 2024-08-10 02:08:54

Build Qt 4.8 in windows by VS2005的相关文章

初步剖析QT事件处理全过程(Windows)

一.说起Qt事件处理,在windows平台下,当然离不开Win32: Win32程序的基本结构: 1.注册窗口: 2.创建窗口: 3.启动由GetMessage和DispatchMessage构成的事件循环: 4.被注册的回调函数 WndProc 负责相应各类事件: Windows会为当前执行的每个Windows程序维护一个消息队列: 以上即简单介绍Windows消息处理流程: 二.QT事件入口类: QApplication :public QGuiApplication :public QCo

Qt开发程序在Windows 10应用需要管理员运行的解决思路

Qt开发程序在Windows 10应用需要管理员运行的解决思路 过了很长的时间没有发布博客了,但是我依然努力地开发Qt程序.目前呢,我发现开发Qt程序在Windows 10上有一个怪现象--有些程序右下角加上了盾牌的标志.那这个为什么呢? 原来是因为我的程序名称包含了Patch,结果就包含了加上了盾牌的标志.如果我去掉了Patch标志,盾牌就消失了.原来Windows对于文件名的一些敏感字,会选择性地做出一些防御操作.看来Windows 10在给我们安全的同时还给我们带来了"意想不到"

configure for build qt5.3.1 static windows/linux

windows: configure -debug -static -opensource -opengl desktop -nomake examples -nomake tests -qt-libpng -qt-libjpeg -prefix f:\Qt5.3.1\win32_static_2013 Linux: configure -debug -opensource  -static -platform linux-g++  -no-ssse3 -no-sse4.1 -no-sse4.2

Qt开发环境搭建 - Windows + VS2010 + VS插件

Qt 开发环境搭建 - Windows+VS2010+VS插件 1.Qt在Windows平台下的三种开发环境 方案 编辑器 编译器 调试器 一 Qt Creator MinGW GDB 二 Qt Creator VisualC++ 编译器 Debugging Tools for Windows 三 VS2010自带 VS2010自带 VS2010自带 说明: 1) C/C++语言.Qt库.开发环境.操作系统的关系 2) 编辑器.编译器.调试器三者的关系 2.1) 三者共同组成了开发环境 2.2)

Create a Qt Widget Based Application—Windows

This turtorial describes how to use Qt Creator to create a small Qt application, Text Finder. It is a simplified version of the Qt UI Tools Text Finder Example. The application user interface is constructed from Qt widgets by using Qt Designer. The a

Qt 5.5.0 Windows环境搭建

1)访问官方网站:http://www.qt.io/download-open-source/ 2)选择离线安装包 3)选择 Windows 离线安装包(32 位或 64 位都可用,Windows 64位向下兼容 32 位,无所谓 32 位或 64 位) 此版本已上传到百度云盘,请点此链接下载:http://pan.baidu.com/s/1bn9Bcdx 4)安装软件包 双击软件包即可安装,开头有个Qt账号注册信息,直接跳过即可,默认配置,一路"下一步"安装. 安装结束后,Qt Cr

Qt 程序在 Windows 下的发布

本文讨论在 Windows 平台下编译成功的 Qt 程序,如何在未配置 Qt 开发环境的 Windows 平台下独立运行的方法. 经过验证发现,在 Ubuntu 平台下编译成功的程序可在未安装 Qt 开发环境下的 Ubuntu16.04 中运行,所以,本文仅讨论,在 Windows 平台下编译成功的 Qt 程序,在未配置 Qt 开发环境的 Windows 平台下独立运行的方法. 1. 编译模式选择 如若想要发布程序,在 IDE 中编译一定要选择 release 而不是 debug,编译成 rel

让Qt for Windows Phone 8.1在真机上运行

前面几篇博文是为这篇文章做铺垫的,最终目的为的是使用Qt框架制作出能够在Windows Phone 8.1真机上运行的程序.由于Qt for WP8这一块不完善,在加上我刚进入这一领域,所以研究的速度有点儿慢.在网上询问了Qt项目的维护者,加上自己的一点研究,稍微了解了Qt for Windows Phone 8的开发原理. 原创文章,反对未声明的引用.原博客地址:http://blog.csdn.net/gamesdev/article/details/38967749 使用Qt开发Windo

搭建Qt 5.3.1 for Windows Phone 8开发环境

目前Qt已经支持了Android以及iOS的开发,我也亲自尝试过在Android和iOS上的开发,其中在Android这一块研究的较深,也制作出了第一款独立游戏<吃药了>.在Qt的新版本5.3的发布中,官方宣布支持WindowsPhone 8/8.1的开发.过了两个月了,我也积极尝试一下,看看使用最新的Qt 5.3.1版本如何搭建WP8的开发环境. 原创文章,反对未声明的引用.原博客地址:http://blog.csdn.net/gamesdev/article/details/3856890