More thorough tutorials/examples for subdirs projects?

  • I have recently started playing with 'TEMPLATE = subdirs' in my project file, but this seems to be a bit sparsely documented. Basically, my goal is to build one or more shared libraries, some tests, and an application which depends on the shared libraries, deploy everything into the right spot, and easily let me run/debug my application. Eventually, I also want to include automating some SWIG stuff for generating python bindings to my shared library as part of the automatic build process.

    I have found some trivial examples, which build a simple library, but automatically put it in a spot that is easy to link to the application is quite a bit of extra work. At the moment, I am hard coding library paths and names on Linux and Windows, and it sort of works on Windows. But, while I have gotten it to link on Linux, the dynamic linker doesn't look in the local directory at run time, so I can't run the app from the IDE. If I set LD_LIBRARY_PATH=. I can run the app from a shell, but that's obviously not ideal.

    Is there any sort of end-to-end tutorial that covers best practices for this sort of 'advanced' qmake usage? Or some repository of good example projects for how to do these things? Qmake seems quite powerful, but once you get off the beaten path, it seems to become quite mysterious...

  • Moderators

    Not exactly a tutorial, but feel free to take a look at my spdr project: "link":

    Does exactly what you want to achieve: there is a library (libspdr) that is being linked to some apps (CLI and GUI) and tests.

    Especially take a look at libraryincludes.pri file and definitions.pri file: they are used throughout my project. You can open the main .pro in Qt Creator and it should work out of the box (just remember to turn of shadow builds).

  • Thanks for this. I haven't had a chance to fully dig into you example as I've been dealing with some other projects, but I am looking forward to making some time this week. Much appreciated.

  • So, I did eventually convert my application to generating a few shared libraries, with an app and tests that depend on them. It's pretty sweet. (Haven't tried to build on Windows since I refactored it. I probably have some import/export nonsense to deal with there, but it should be manageable.) But, losing shadow builds is a bit of a bummer. Have you looked at this?

    I think my next step will be to try using that to get the .pro files working with shadow building again, even with the shared lib generation. Slowly piecing it all together. I think I'll finally have qmake figured out just in time for it to be deprecated in favor of qbs...

  • Moderators

    Ha, I did not know about shadowed() function, it sure looks useful! Thanks :-)

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.