C++ 为 Visual Studio 2012 编译 Qt 4.8.x

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12113400/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 15:53:36  来源:igfitidea点击:

Compiling Qt 4.8.x for Visual Studio 2012

c++qtvisual-studio-2012

提问by Smi

What steps should I take to compile Qt (version 4.8.x) for Visual Studio 2012?

我应该采取哪些步骤来为 Visual Studio 2012 编译 Qt(版本 4.8.x)?

I already carefully followed the instructions in the accepted answer of this question(which is for VS 2010), but WebKit module failed to compile (I'm not sure if the error message was logged anywhere during compilation).

我已经仔细遵循了这个问题的已接受答案中的说明(适用于 VS 2010),但是 WebKit 模块无法编译(我不确定在编译期间是否记录了错误消息)。

I also saw this questionwhich asks the same, but for VS 2012 RC (which is why I thought this wouldn't be a duplicate question). Furthermore, the answerer says he has compiled Qt for VS 2011 Beta, so there's a chance it may not work for VS 2012 (RTM). The compilation takes a lotof time, which is why I have not tried it yet.

我也看到了这个问题,但对于 VS 2012 RC(这就是为什么我认为这不会是一个重复的问题)。此外,回答者说他已经为 VS 2011 Beta 编译了 Qt,所以它可能不适用于 VS 2012 (RTM)。编译需要很多时间,所以我还没有尝试过。

At least one problem I realized is that there's no win32-msvc2012directory in Qt\mkspecs. Should I just create that directory and copy the files from win32-msvc2010, possibly with some modifications?

至少有一个问题,我意识到的是,有没有win32-msvc2012在目录中Qt\mkspecs。我是否应该创建该目录并从中复制文件win32-msvc2010,可能需要进行一些修改?

Another sub-question is whether I should make some modifications to Qt sources before starting compilation.

另一个子问题是我是否应该在开始编译之前对 Qt 源代码进行一些修改。

回答by Vertexwahn

Qt 4.8.3 with Visual Studio 2012 x64 (should also work with 4.8.2)

Qt 4.8.3 与 Visual Studio 2012 x64(也应与 4.8.2 一起使用)

  1. Install Strawberry Perl

  2. Download Qt 4.8.3 source code from http://qt-project.org/downloads

  3. Go to mkspecs\win32-msvc2010. Open qmake.confand change:

    QMAKE_COMPILER_DEFINES  += _MSC_VER=1600 WIN32
    

    to:

    QMAKE_COMPILER_DEFINES  += _MSC_VER=1700 WIN32
    
  4. Replace qt-everywhere-opensource-src-4.8.3-x64\src\3rdparty\webkit\Source\JavaScriptCore\wtf\HashSet.hby this HashSet.h.

  5. Start "VS2012 x64 Native Tools Command Prompt"

  6. Switch to Qt 4.8.3 source directory (the directory that contains configure.exe)

  7. Run:

    configure -mp -opensource -nomake demos -nomake examples -platform win32-msvc2010
    
  8. Followed by:

    nmake
    
  1. 安装草莓 Perl

  2. http://qt-project.org/downloads下载 Qt 4.8.3 源代码

  3. mkspecs\win32-msvc2010。打开qmake.conf和更改:

    QMAKE_COMPILER_DEFINES  += _MSC_VER=1600 WIN32
    

    到:

    QMAKE_COMPILER_DEFINES  += _MSC_VER=1700 WIN32
    
  4. 更换qt-everywhere-opensource-src-4.8.3-x64\src\3rdparty\webkit\Source\JavaScriptCore\wtf\HashSet.h这个HashSet.h

  5. 启动“VS2012 x64 Native Tools 命令提示符”

  6. 切换到 Qt 4.8.3 源目录(包含 的目录configure.exe

  7. 跑:

    configure -mp -opensource -nomake demos -nomake examples -platform win32-msvc2010
    
  8. 其次是:

    nmake
    

I programmed a tool called BlueGo which automatically downloads Qt 4.8.3 and builds it with VS2012 x64: http://bluego.vertexwahn.de(also works with VS2010 x64) (it just does what I described above automatically)

我编写了一个名为 BlueGo 的工具,它会自动下载 Qt 4.8.3 并使用 VS2012 x64 构建它:http://bluego.vertexwahn.de (也适用于 VS2010 x64)(它只是自动执行我上面描述的操作)

回答by cbielow

Qt 4.8.4 needs less tweaking than described by Vertexwahn above.

Qt 4.8.4 需要的调整比上面 Vertexwahn 描述的要少。

  • The HashSet still has to be fixed (see fix of Vertexwahn) after Qt has been extracted from archive.
  • Platform win32-msvc2012 is supported out-of-the-box though (also works for 64bit in the 64bit environment, don't ask why they name it Win32).
  • 从存档中提取 Qt 后,HashSet 仍然需要修复(请参阅Vertexwahn 的修复)。
  • 平台 win32-msvc2012 支持开箱即用(在 64 位环境中也适用于 64 位,不要问他们为什么将其命名为 Win32)。

So simply replace the HashSet.h and compile.

所以只需替换 HashSet.h 并编译。

回答by Florian George

Just creating a win32-msvc2012 directory with the changes below didn't work for me, there is more editing necessary. What exactly is necessary is described in the thread you already linked.

仅使用以下更改创建一个 win32-msvc2012 目录对我不起作用,需要进行更多编辑。您已经链接的线程中描述了究竟需要什么。

What I did, I went to win32-msvc2010.

我做了什么,我去了win32-msvc2010。

There, open qmake.conf and change

在那里,打开 qmake.conf 并更改

QMAKE_COMPILER_DEFINES += _MSC_VER=1600 WIN32

QMAKE_COMPILER_DEFINES += _MSC_VER=1600 WIN32

to

QMAKE_COMPILER_DEFINES += _MSC_VER=1700 WIN32

QMAKE_COMPILER_DEFINES += _MSC_VER=1700 WIN32

Then I could configure using win32-msvc2010.

然后我可以使用 win32-msvc2010 进行配置。

Also, I used these changes: http://qt-project.org/forums/viewthread/17771(alzi's Version)

另外,我使用了这些更改:http://qt-project.org/forums/viewthread/17771(alzi 的版本)