Qt Creator how to run SUBDIRS projects

旧城冷巷雨未停 提交于 2019-11-29 11:21:00

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.

Just create your "master-app". Then edit the .pro File from these app:

TEMPLATE = subdirs

but before you do anything else! This is important!

You can remove all the sourcefiles

SOURCES += \ ...
HEADERS += \ ...
FORMS += \ ...
etc

But this is your master-app! Just the profile! ok, and yourappname.pro.user ;-) Later you can add f.e. an window-app.

Then you can create an another project, f.e. a dll. For this new subbroject you can choose any directory you want :-)

For add: click on the "master-app" right mousebutton and chosse "Add subproject" from the contextmenu.

The last step, before you close the "new subproject-dialog" you should select the master project in a combobox.

That's it! More is not nessesary

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!