Qt Creator如何运行SUBDIRS项目 [英] Qt Creator how to run SUBDIRS projects
问题描述
我已经使用Qt Creator一段时间了,我的项目越来越大,我想转到使用
如果我右键单击project1,它将显示运行选项。但是,要使其在这里工作,整个 master.pro必须能够正确编译。
我知道这是一种解决方法,我可以加载project1 .pro本身,但我想加载master.pro并从子项目中运行它。
在此方面的任何帮助将不胜感激。
不是我所有的项目都准备好运行代码,如何选择一个项目到
运行,是否具有subdir根项目?
您可以维护几个 TEMPLATE = app
项目以启动代码的一部分,例如,对选定库以及整个应用程序GUI启动器进行单元测试。并尝试在 TEMPLATE = lib
类型的项目中隔离尽可能多的共享代码。 lib
类型的项目需要是静态库还是动态库,并带有 DEFINES + = SHAREDLIB_LIBRARY
是另一个问题,并且答案取决于您分发应用程序的方式。我维护我当前的 subdir
项目,其中包含许多动态库,以防止由于内存限制而将它们始终链接到可执行文件。
打开项目菜单,并确保运行配置指向包含主要功能并具有以下功能的应用程序项目:
#app.pro文件包含
模板= app
以及
#unit_test1.pro文件包含
TEMPLATE = app
如果某些项目无法编译,请将其从子目录
项目中排除:
TEMPLATE =子目录
SUBDIRS = lib单元测试
#SUBDIRS = lib单元测试app#应用未准备好
#app.depends = lib#可能不包括依赖项
unit-test.depends = lib
Mind'运行配置'在下面选择已开始的项目:
聚苯乙烯在项目文件更改后,请不要忘记运行qmake。
I've been using Qt Creator for a while now and my project is getting large enough that I'd like to move to using Qt's SUBDIRS template type to better organize my growing project.
The structure of my project is similar to the following
/master
|--- master.pro
`--- project1
| |--- project1.pro
| `--- ... (source files specific to project1)
`--- project2
| |--- project2.pro
| `--- ... (source files specific to project2)
`--- shared
`--- ... (source files shared between project1 and project2)
Both project1 and project2 are separate independent projects, but that have some source/header files that they share for convenience and maintainability in the shared folder.
The bulk of my development time generally is spent working on the shared files and project1. So as I make changes to shared files both project1 and project2 must, in the end, be updated to work with these shared file.
My problem is, say I've just made changes to shared files AND project1 but have not yet updated project2. How do I, from QtCreator run project1 so I can test my changes? Obviously at the end of the day/week/month I'd fix project2 to work with these changes, but how would I run project1 in the mean time?
If I right-click on project1, it shows the "run" option. However, for this to work here, the entire "master.pro" has to be able to compile without errors.
I know as a workaround, I could just load project1.pro by itself, but I'd like to load master.pro and run it from the subproject.
Any help on this would be greatly appreciated.
Not all of my projects ready to run the code, how can I select one project to run, having subdir root project?
You can maintain several TEMPLATE = app
projects to start parts of your code, say, unit tests for selected libraries as well as the entire app GUI starter. And try to isolate as much of shared code possible in TEMPLATE = lib
types of projects. Whether the lib
type of project needs to be a static library or dynamic with DEFINES += SHAREDLIB_LIBRARY
is another question and the answer depends on how you distribute the app. I maintain my current subdir
project with many dynamic libraries to prevent them being linked to executable all the time due to memory restrictions.
Open 'Projects' menu and make sure that Run Configuration points to your application project that contains main function and has:
# app.pro file contains
TEMPLATE = app
and also
# unit_test1.pro file contains
TEMPLATE = app
If some of your projects won't compile, exclude it from subdirs
project:
TEMPLATE = subdirs
SUBDIRS = lib unit-test
# SUBDIRS = lib unit-test app # app not ready
# app.depends = lib # may exclude dependcies
unit-test.depends = lib
Mind 'Run configuration' choice of started projects below:
P.S. Don't forget to run qmake after project file changed.
这篇关于Qt Creator如何运行SUBDIRS项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!