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

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

问题描述

我找不到任何有关如何在Windows上安装Qt的信息。

在wiki文章如何在Mac和Linux上设置阴影构建 configure 脚本中描述 -prefix 选项但是这个选项在Windows上不可用。

我知道我可以从build文件夹中使用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.

推荐答案

在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. 移动 br>
    将构建文件夹复制到要安装Qt的位置。 c $ c $

  3. 修复 qmake.exe executable

    运行 qmake -query 以查看将哪些路径编译(硬编码)到qmake和

    a。修复包含构建文件夹的路径,使用 qmake -set (1)将其替换为 INSTALL_DIR



    b。在以下位置创建 qt.conf 文件 INSTALL_DIR 的bin子文件夹,在其中指定新的Qt路径。

  4. 添加当前目录以包含路径

    在Qt提供的二进制发行版中,pwd包含在 QMAKE_INCDIR ,因此最终在您的项目中包含路径为。。这不会在默认情况下发生在自定义构建的Qt,所以你必须添加以下行到 mkspecs / YOUR-PLATFORM-HERE / qmake.conf 文件:

    QMAKE_INCDIR + =。

  5. 修复 prl 文件

    当您将Qt组件添加到项目文件(例如 CONFIG + = uitools )时, code>%QTDIR%/ lib / QtUiTools.prl
    来查找该组件的库依赖关系。这些文件将具有配置和构建Qt的目录的硬编码路径。你必须用你移动Qt的所有 lib / *。prl 文件替换该构建目录。

  6. 使源可用

    如果您进行了阴影构建(在一个文件夹以外的文件夹中构建) 仅包含子文件夹转发到原始标题。例如; BUILD_DIR\include\QtCore\qabstractanimation.h 看起来像这样

    #includeSRC_DIR / src / corelib /动画/ 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_DIR\include\QtCore\qabstractanimation.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构建过程真正的akward移动(安装)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留下的文件夹中,在此文件夹中进行构建。

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_USER \Software \Trolltech\QMake\< QMAKE_VERSION> 。 br>
因为这个,你可能有一个问题,当你想有不同的项目使用不同版本的Qt,恰巧有相同版本的qmake。在这种情况下,更好的解决方案是使用 qt.conf 文件(实际上是文件,因为每个Qt安装需要一个文件)(选项3b)。

1)
The variables you set with qmake -set are saved in the registry key
HKEY_CURRENT_USER\Software\Trolltech\QMake\<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安装程序的预建二进制文件与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.

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

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