构建后如何在Windows上安装Qt? [英] How to install Qt on Windows after building?

查看:32
本文介绍了构建后如何在Windows上安装Qt?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到有关如何安装在 Windows 上构建的 Qt 的任何信息.
在 wiki 文章 How to set up shadow builds on Mac and Linux 中有 的描述configure 脚本中的 -prefix 选项,但此选项在 Windows 上不可用.
我知道我可以直接从构建文件夹中使用 Qt,但不执行安装步骤似乎是不对的.这种方法的一个问题是尺寸;Qt 的构建文件夹大约需要 4GB 空间,而在使用二进制安装程序安装后,Qt 大约需要 1GB 空间.我想差异是由于构建过程中创建的临时文件.我希望一些安装程序会安装(复制)只需要的文件,而在构建文件夹中保留临时文件.

I can't find any information on how to install Qt built on Windows.
In wiki article How to set up shadow builds on Mac and Linux there's description of -prefix option in configure script but this option is not available on Windows.
I know I can use Qt right from the build folder but it does not seem the right thing not to perform an install step. One problem with this approach is size; Qt's build folder takes about 4GB space whereas after installing using binary installer Qt takes about 1GB space. I guess the difference is due to temporary files created during building. I hope some install procedure would install (copy) only needed files leaving temporary files in the build folder.

推荐答案

正如 İsmail 所说,在 Windows 上没有安装 Qt 的步骤.但是可以尝试通过执行以下操作来近似它.

As İsmail said there's no install step for Qt on Windows. However one can try to approximate it by performing the following operations.

  1. 清洁
    在构建文件夹中运行 make clean 以删除所有临时文件.
  2. 搬家
    将构建文件夹复制到您想要安装"Qt 的位置.我们称之为INSTALL_DIR.
  3. 修复在 qmake.exe 可执行文件中硬编码的路径
    运行 qmake -query 以查看哪些路径被编译(硬编码)到 qmake 和
    一种.通过使用 qmake -set (1) 将包含构建文件夹的路径替换为 INSTALL_DIR 来修复路径.

    湾在INSTALL_DIR 的 bin 子文件夹,指定其中的新 Qt 路径.
  4. 添加当前目录以包含路径
    在 Qt 提供的二进制发行版中,pwd 包含在 QMAKE_INCDIR 中,因此在您的项目中最终包含路径为.".这在自定义构建的 Qt 中默认不会发生,因此您必须将以下行添加到 mkspecs/YOUR-PLATFORM-HERE/qmake.conf 文件:
    QMAKE_INCDIR += "."
  5. 修复prl文件
    当你在项目文件中添加Qt组件(比如CONFIG += uitools)时,Qt会在%QTDIR%/lib/QtUiTools.prl中查找库依赖那个组件.这些文件将具有配置和构建 Qt 的目录的硬编码路径.你必须用你为所有 lib/*.prl 文件移动 Qt 的那个目录替换那个构建目录.
  6. 提供源代码
    如果您进行了影子构建(在包含源的文件夹之外的文件夹中构建),include 子文件夹中的标题只会转发到原始标题.例如;BUILD_DIRincludeQtCoreqabstractanimation.h 看起来像这样
    #include "SRC_DIR/src/corelib/animation/qabstractanimation.h"
    如果您不想依赖包含源的文件夹的存在,您必须将 SRC_DIR/src 子文件夹复制到目标文件夹并修复 include 文件夹中的所有标题以便他们转发到 src 子文件夹的新位置.
  1. Cleaning
    Run make clean in the build folder to remove all temporary files.
  2. Moving
    Copy build folder to the place where you want Qt "installed". Let's call it INSTALL_DIR.
  3. Fixing paths hardcoded in the qmake.exe executable
    Run qmake -query to see what paths are compiled (hardcoded) into qmake and
    a. Fix paths containing the build folder by replacing it with the INSTALL_DIR using qmake -set (1).
    or
    b. Create a qt.conf file in the bin subfolder of the INSTALL_DIR specifing new Qt paths inside it.
  4. Adding current directory to include path
    In Qt's provided binary distributions, the pwd is included in the QMAKE_INCDIR and thus ends up in your projects include path as ".". This does not happen by default in a custom built Qt, so you have to add the following line to mkspecs/YOUR-PLATFORM-HERE/qmake.conf file:
    QMAKE_INCDIR += "."
  5. Fixing prl files
    When you add a Qt component to a project file (such as CONFIG += uitools), Qt looks in %QTDIR%/lib/QtUiTools.prl to find the library dependencies of that component. These files will have the hard coded path of the directory in which Qt was configured and built. You have to replace that build directory with the one to which you moved Qt for all lib/*.prl files.
  6. Making source available
    If you made a shadow build (build made inside folder other than the one containg sources), headers in the include subfolder only forward to the original headers. For example; BUILD_DIRincludeQtCoreqabstractanimation.h looks like this
    #include "SRC_DIR/src/corelib/animation/qabstractanimation.h"
    If you don't want to depend on the existence of the folder containg sources you have to copy SRC_DIR/src subfolder to your destination folder and fix all headers in the include folder so that they forward to the new location of src subfolder.

底线:
Windows 下 Qt 的构建过程使得在构建后移动(安装)Qt 真的很尴尬.只有在……我找不到任何好的理由来解决所有这些麻烦时,你才应该这样做.

The bottom line:
The build process of Qt under Windows makes it really akward to move (install) Qt after building. You should do this only if ... well I can't find any good reason to go through all this trouble.

记住
简单的方法是将 Qt 的源代码放在您希望 Qt 在构建后保留的文件夹中,并在此文件夹中进行构建.这使得除上述 1 和 4 之外的所有步骤都变得不必要.

Remember
The easy way is to place Qt's sources in the folder where you want Qt to stay after building and make a build in this folder. This makes all steps but 1 and 4 above unnecessary.

1)
您使用 qmake -set 设置的变量保存在注册表项中
HKEY_CURRENT_USERSoftwareTrolltechQMake.
因此,当您希望使用不同版本的 Qt 的不同项目恰好具有相同版本的 qmake 时,您可能会遇到问题.在这种情况下,更好的解决方案是使用 qt.conf 文件(实际上是文件,因为每个 Qt 安装都需要一个文件)(选项 3b).

1)
The variables you set with qmake -set are saved in the registry key
HKEY_CURRENT_USERSoftwareTrolltechQMake<QMAKE_VERSION>.
Because of this you might have a problem when you would like to have different projects using different versions of Qt which happen to have the same version of qmake. In this case the better solution is to use qt.conf file (actually files as you need one file for each Qt installation) (option 3b).

以上许多信息来自 RelocationTricks wiki由 Gabe Rudy 撰写的页面.查看他的 Qt (Qt4) Opensource Windows Installers of Pre-built Binaries with MSVC 2008 项目,可让您轻松解决上述问题.

Many of the information above come from the RelocationTricks wiki page authored by Gabe Rudy. Check out his Qt (Qt4) Opensource Windows Installers of Pre-built Binaries with MSVC 2008 project which gives you easy solution of above problems.

这篇关于构建后如何在Windows上安装Qt?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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