Sharing projects between sub_dir projects
-
I am building multiple programs that share libraries between them. I have been using a sub_dir project to build one of the programs and need to create a new program that shares some, but not all of the library projects from the first program.
How would I go about doing that in Qt Creator?
-
I usually use additional files for .pro projects, like this:
@
// .pro
include(libraryIncludes.pri)// libraryIncludes.pri
LIBS += -lsome/path -LsomeLib
INCLUDEPATH +=some/include/path
@ -
Perfect. Thanks!
Is there anyway to extend this to include the source code so that I can step into it with the debugger and make changes if necessary?
-
It should work out of the box, I think. The INCLUDEPATH allows you to include library headers in your other (sub)project, and the debugger should be able to see those headers, too.
-
I thought I had it worked out, but it doesn't seem to be working. It's not clear (to me) where each of those files goes.
If it's not asking too much, could you please let me know how the layout should be if I have the following projects?
sub_dirs - MainProject
app - Driver
staticLib - libA
staticLib - libB
staticLib - libCThe lib* projects already exist and I would like to share them between multiple sub_dirs projects, Driver is a driver program that utilizes libA, libB and libC.
I've tried several different layouts and either Qt can't find the .pro files or the Driver program can't find the include files for the libraries.
Thanks for the help.
-
qmake is very limited when it comes to SUBDIRS: all subprojects you name in the variable need to be placed in a directory with exactly the same name, and in that folder, there needs to be a .pro file - again with the same name. So for your case I would recommend going one dir up and creating a root .pro file there. Like this:
@
root.pro (SUBDIRS)
| sub_dirs
| app
| libA
| libB
| libC
@
Then you can also use the DEPENDS qmake variable to instruct qmake that libraries need to be built before sub_dirs.