如何使用Visual C ++ 2010 Express在32位环境中为64位Windows编译Qt? [英] How to compile Qt for 64-bit Windows from a 32-bit environment with Visual C++ 2010 Express?

查看:125
本文介绍了如何使用Visual C ++ 2010 Express在32位环境中为64位Windows编译Qt?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为64位Windows编译Qt库(不需要演示或示例)。在此处有说明,但我遇到了下面注释中所述的错误。似乎到处都没有关于如何执行此过程的参考。

I am trying to compile the Qt library (I don't need the demos or examples) for 64-bit Windows. There are instructions here but I run into the error described in the comment below it. There doesn't seem to be a reference anywhere for how one might go about doing this process.

我的目标是Microsoft Visual C ++ 2010 Express。看来我也需要Perl和Windows SDK-我该如何进行该过程?

I am targetting Microsoft Visual C++ 2010 Express. It looks like I need Perl and the Windows SDK as well - how do I go about this process?

推荐答案

繁琐且费时的工作-但我将在此处详细说明每个步骤,以帮助其他将来尝试编译Qt的人员。

This process is quite tedious and time-consuming - but I will explain each step in detail here for the benefit of others who try to compile Qt in the future.


  1. 第一步是安装所有必备组件。

  1. The first step is to install all of the prerequisites.


  • ActivePerl ,它在配置过程中使用。安装Perl后,您将需要重新启动,因为它会修改环境变量。

  • Windows SDK 7.1 (以前称为Platform SDK)。选择要安装的组件时,请确保包括x64库。


  • ActivePerl, which is used during the configuration process. You will need to restart after installing Perl since it modifies environment variables.
  • The Windows SDK 7.1 (formerly called the Platform SDK). Be sure to include the x64 libraries when you select the components to install.

下载 Qt下载页面

将档案的内容提取到易于记忆的位置(例如 C:\ )。您稍后需要记住该位置,因为我们将使用它来设置一些环境变量。

Extract the contents of the archive to an easy-to-remember location (like C:\). You need to remember this location later since we will be using it to set some environment variables.

现在打开Windows SDK 7.1命令提示符。首先将环境设置为32位发布模式(我们需要将某些工具构建为32位应用程序):

Now open the Windows SDK 7.1 Command Prompt. Begin by setting the environment to 32-bit release mode (we need to build some of the tools as 32-bit applications):

setenv /release /x86


  • 设置以下环境变量(以下示例假定您提取到 C:\ ):

    set QTDIR=C:\qt-everywhere-opensource-src-4.8.0
    set PATH=%PATH%;%QTDIR%\bin
    


  • 现在运行 cd%QTDIR%并指定配置选项-示例如下:

  • Now run cd %QTDIR% and specify the configuration options - example is included below:

    configure -release -opensource -qt-zlib -qt-libpng -qt-libmng -qt-libtiff
     -qt-libjpeg -qt-style-windowsxp -qt-style-windowsvista -platform
     win32-msvc2010
    


  • 配置完成后完成后, cd src 目录并运行:

    qmake
    nmake
    

    此过程可能需要相当大的一笔时间不多,所以现在是休息一下并在Stack Overflow上回答一些问题的好时机:)

    This process may take a considerable amount of time, so now would be a good time to take a break and answer some questions here on Stack Overflow :)

    现在已经构建了工具,您可以需要将Qt编译为64位库。输入以下命令:

    The tools are now built and you need to compile Qt as a 64-bit library. Enter the following command:

    setenv /x64
    

    您将需要再次设置步骤5中的环境变量。立即输入这些命令。

    You will need to set the environment variables from step 5 again. Enter those commands now.

    运行 cd%QTDIR%,然后重新运行 configure 命令确保指定一个附加选项

    Run cd %QTDIR% and then rerun the configure command being sure to specify one additional option:

    
    configure -release -opensource -qt-zlib -qt-libpng -qt-libmng -qt-libtiff
     -qt-libjpeg -qt-style-windowsxp -qt-style-windowsvista -platform
     win32-msvc2010 -no-qmake
    

    -no-qmake 选项为非常重要-它表示我们要跳过 qmake.exe 程序的编译,因为我们要保留32位版本。

    The -no-qmake option is very important - it indicates that we want to skip the compilation of the qmake.exe program because we want to keep the 32-bit version.

    由于某些依赖问题,现在事情变得很复杂。 Qt用来构建核心库的工具(例如 moc )以及其他一些组件在 src.pro 文件。这意味着编译器将尝试将它们构建为64位应用程序,然后尝试运行它们-当然,这将在32位系统上失败。因此,我们需要做的是编辑 src.pro 并自行删除这些依赖项。向下滚动至第85行附近,然后查找以以下内容开头的行:

    Now things get really complicated here because of some dependency problems. The tools (like moc) that Qt needs to build the core library and some of the other components are listed as dependencies in the src.pro file. This means that the compiler will attempt to build them as 64-bit applications and then try to run them - which will of course fail on a 32-bit system. So what we need to do is edit src.pro and remove those dependencies ourselves. Scroll down near line 85 and look for a line that begins with:

    !wince*:!ordered:!symbian-abld:!symbian-sbsv2 {
    

    本节中的每一行都列出了一个子目标及其依赖项。现在,您要删除以 src_tools _ 开头的所有依赖项。例如:

    Each subsequent line in the section lists a sub-target and its dependencies. What you want to do now is remove all dependencies that begin with src_tools_. For example:

    src_gui.depends = src_corelib src_tools_uic
    

    成为:

    src_gui.depends = src_corelib
    

    也许有更好的方法,但是我还没有弄清楚:)

    There might be a better way of doing this, but I haven't figured it out yet :)

    现在我们再次 cd 进入 src 目录并运行以下命令命令

    Now we cd into the src directory once again and run the following command

    nmake sub-winmain sub-corelib sub-xml sub-network sub-sql sub-testlib
     sub-gui sub-qt3support sub-activeqt sub-opengl sub-xmlpatterns sub-phonon
     sub-multimedia sub-svg sub-script sub-declarative sub-webkit
     sub-scripttools sub-plugins sub-imports
    

    这仅生成 Qt库,并跳过了工具依赖项。请注意,这也可能需要花费大量时间。

    This builds only the Qt libraries and skips the tool dependencies. Note that this too may take a considerable amount of time.

    您现在应该在 lib 文件夹。






    编辑:事实证明,这还不够,因为在链接 QtWebKit4.dll 库(关于未解析符号的内容)。原来,其他人已经找到解决方案,您需要将<$ c $中的 QMAKE_HOST.arch 更改为 QMAKE_TARGET.arch c> WebCore.pro


    it turns out that even this wasn't enough since I still ran into some problems when linking the QtWebKit4.dll library (something about unresolved symbols). It turns out that someone else has already found the solution and you need to change QMAKE_HOST.arch to QMAKE_TARGET.arch in WebCore.pro.

    此外,以上选项还将在没有OpenSSL支持的情况下构建QNetwork4.dll(您将无法访问通过HTTPS的网站-甚至在QWebView中)。值得庆幸的是,这个问题并不太难解决。下载并为Win64构建 OpenSSL ,然后在步骤#9中将以下选项附加到命令中:

    Also, the above options will build QNetwork4.dll without OpenSSL support (you won't be able to access sites over HTTPS - even in a QWebView). This, thankfully isn't too hard to fix. Download and build OpenSSL for Win64 and append the options below to the command in step #9:

    -openssl -I C:\OpenSSL\inc32 -L C:\OpenSSL\out32dll
    

    (如果您在 C:\OpenSSL 。)

    进一步编辑:为节省您自己这样做的麻烦,我已在此处上传已编译的库:

    http://www.box.com/s / 9710cbb278ef4890a7b5

    Further edit: to save the trouble of doing this yourself, I have uploaded the compiled libraries here:
    http://www.box.com/s/9710cbb278ef4890a7b5

    这篇关于如何使用Visual C ++ 2010 Express在32位环境中为64位Windows编译Qt?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆