Mohamed Samy
Mohamed Samy

Reputation: 178

Qt Creator: Projects that use other projects as libraries

I've written a small library as a Qt project using Qt Creator, now I want to create a small GUI application that can be used to test it as part of the development process, so it could be like this:

Project root at:

~/code/mylib

Library project and associated code:

~/code/mylib/corelib/corelib.pro

GUI test tool and associated code:

~/code/mylib/libgui/guitool.pro

So far I've only been able to make things work by setting up LIBS+= in the GUI project's .pro file, manually building the library, copying the library's .a file to the GUI directory, and rebuilding the GUI project. A tedious process. Worse: I'm developing the project now on Linux but need to make it build on Linux and Windows, and this manual build style will probably make that harder.

I suppose there's a way to do make Qt Creator aware of the relationships between the projects, so for example building the GUI tool in debug mode use the debug version of the library, or making changes to the corelib would necessitate a build in the GUI, building on some OS would use the libraries OS-configuration...etc

This kind of thing is a couple of clicks away in Eclipse and Visual Studio, but I can't seem to get it working in QtCreator. I've tried "Add library->Internal library" and creating a 'subdirs' project but neither seems to work. I feel it's probably a simple step that I'm missing somewhere, any help?

Upvotes: 2

Views: 2054

Answers (1)

Sergey Shambir
Sergey Shambir

Reputation: 1592

Try again to use subdirs feature. It have own wizard "Project with subdirectories", but in your case it's easier to write it manually (in example I've added "ordered" to ensure that order of compilation is always correct).

TEMPLATE  = subdirs
CONFIG   += ordered 
SUBDIRS = corelib guitool

Than you can add libary to your GUI application with wizard (accessible from context menu inside .pro).

Upvotes: 2

Related Questions