从命令行构建 Qt Creator 项目

发布于 2024-11-09 09:39:33 字数 297 浏览 0 评论 0原文

我正在编写构建脚本来自动执行构建和发布任务。我有一个 Qt Creator 项目,它具有三个配置,其中两个我想从头开始完全重建,而不需要任何预编译头和现有的 .o 文件来跳过(release 和 release_product)。后者是相同的,只是它具有#define 生产符号。

我正在使用窗户。如何从命令行构建这些配置?

编辑:一些澄清:Qt Creator 自定义构建步骤不存储在 qmake makefile 中,而是存储在 Qt Creator 特定的 .pro.user XML 文件中。我想从命令行执行这些操作,而不在脚本中重复它们。

I'm in the process of writing a build script to automate build and release tasks. I have a Qt Creator project which has three configurations, two of which I want to completely rebuild from scratch without any precompiled headers and existing .o files to skip (release and release_production). The latter is the same except it has the PRODUCTION symbol #defined.

I'm using windows. How can I build these configurations from the command line?

Edit: Some clarification: The Qt Creator custom build steps are not stored in the qmake makefile but in the Qt Creator-specific .pro.user XML file. I would like to perform these from the command line without repeating them in the script.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

演多会厌 2024-11-16 09:39:33

这里涉及两个步骤:

  1. 运行qmake来生成Makefile。通常的命令是

    c:\qt\4.7.2\bin\qmake.exe" path\to\some\project.pro -r -spec win32-g++ CONFIG+=...
    

    -spec 开关很重要。确保您提供有效的 makespec 文件。此步骤需要指定CONFIG

  2. 运行make进行编译和链接。这很容易

    C:\MinGW32\bin\mingw32-make -f Makefile.Debug
    

    记住将 make 指向正确的 makefile。

There are two steps involved here:

  1. Running qmake to generate Makefiles. The usual command is

    c:\qt\4.7.2\bin\qmake.exe" path\to\some\project.pro -r -spec win32-g++ CONFIG+=...
    

    The -spec switch is important. Make sure you supply a valid makespec file. CONFIG needs to be specified in this step.

  2. Running make to compile and link. This is easy

    C:\MinGW32\bin\mingw32-make -f Makefile.Debug
    

    Remember to point make to the correct makefile.

沧笙踏歌 2024-11-16 09:39:33

在 QtCreator 的项目选项卡中,您有确切的命令,QtCreator 在构建上运行以进行调试和发布。只需在可以构建项目的环境中运行这些行(Qt 控制台)即可。但基本上 Qt 项目是使用 qmake.exe 构建的,然后是 nmake.exe 或 Qt 多线程 make-like 可执行文件 jom.exe

对于“生产”模式,您可以在 qmake 命令中使用 CONFIG+=product 参数,然后在 .pro 文件中使用:

CONFIG(production){
DEFINES+=PRODUCTION
}else{
}

In the project tab of QtCreator you have the exact command, QtCreator runs on build for both debug and release. Just run those lines in a environment your project can be build (Qt console). But basically Qt projects are build with a qmake.exe then a nmake.exe or the Qt multi-thread make-like executable jom.exe.

For your "production" mode your can use CONFIG+=production argument in the qmake command, then in your .pro files :

CONFIG(production){
DEFINES+=PRODUCTION
}else{
}
柠北森屋 2024-11-16 09:39:33

为了使这项工作顺利进行,有一些实际的细节是必要的。

你必须告诉编译器和编译器在哪里。资源处理器位于。例如:

:: CL.EXE
PATH=%PATH%;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64
:: RC.EXE
PATH=%PATH%;C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64

您必须定义 Include 和 Library 路径:

SET INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\atlmfc\include
SET LIB=C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x64;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\atlmfc\lib\x64;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\ucrt\x64

然后您可以这样做:

CD C:\Foo\build-your-project-Desktop_Qt_5_13_0_MSVC2017_64bit-Release
C:\Qt\Tools\QtCreator\bin\jom.exe /S -f Makefile.Release clean

C:\Qt\5.13.0\msvc2017_64\bin\qmake.exe -o Makefile ..\your-project\your-project-file.pro -spec win32-msvc "CONFIG+=qtquickcompiler"

C:\Qt\Tools\QtCreator\bin\jom.exe /S /X Build.log -f Makefile.Release

如果出现错误,请搜索头文件或 lib 文件所在的路径,并将其添加到路径中。不断重复,直到所有错误都消失。

There are a few practical details that are necessary in order to make this work.

You have to tell where the compiler & resource processor are located. Ex:

:: CL.EXE
PATH=%PATH%;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64
:: RC.EXE
PATH=%PATH%;C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64

You have to define Include and Library paths:

SET INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\atlmfc\include
SET LIB=C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x64;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\atlmfc\lib\x64;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\ucrt\x64

Then you can do it:

CD C:\Foo\build-your-project-Desktop_Qt_5_13_0_MSVC2017_64bit-Release
C:\Qt\Tools\QtCreator\bin\jom.exe /S -f Makefile.Release clean

C:\Qt\5.13.0\msvc2017_64\bin\qmake.exe -o Makefile ..\your-project\your-project-file.pro -spec win32-msvc "CONFIG+=qtquickcompiler"

C:\Qt\Tools\QtCreator\bin\jom.exe /S /X Build.log -f Makefile.Release

If you get errors, search for the path where the header or lib file is located, and add it to the paths. Keep repeating until all errors are gone.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文