从命令行构建 Qt Creator 项目
我正在编写构建脚本来自动执行构建和发布任务。我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这里涉及两个步骤:
运行
qmake
来生成Makefile。通常的命令是-spec
开关很重要。确保您提供有效的 makespec 文件。此步骤需要指定CONFIG
。运行
make
进行编译和链接。这很容易记住将
make
指向正确的 makefile。There are two steps involved here:
Running
qmake
to generate Makefiles. The usual command isThe
-spec
switch is important. Make sure you supply a valid makespec file.CONFIG
needs to be specified in this step.Running
make
to compile and link. This is easyRemember to point
make
to the correct makefile.在 QtCreator 的项目选项卡中,您有确切的命令,QtCreator 在构建上运行以进行调试和发布。只需在可以构建项目的环境中运行这些行(Qt 控制台)即可。但基本上 Qt 项目是使用
qmake.exe
构建的,然后是nmake.exe
或 Qt 多线程 make-like 可执行文件jom.exe
。对于“生产”模式,您可以在 qmake 命令中使用
CONFIG+=product
参数,然后在 .pro 文件中使用: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 anmake.exe
or the Qt multi-thread make-like executablejom.exe
.For your "production" mode your can use
CONFIG+=production
argument in the qmake command, then in your .pro files :为了使这项工作顺利进行,有一些实际的细节是必要的。
你必须告诉编译器和编译器在哪里。资源处理器位于。例如:
您必须定义 Include 和 Library 路径:
然后您可以这样做:
如果出现错误,请搜索头文件或 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:
You have to define Include and Library paths:
Then you can do it:
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.