Daniel Langdon
Daniel Langdon

Reputation: 5999

How to organize QtCreator project with libraries

I'm trying to learn QtCreator. I recently needed to create a separate executable to do a unit test, and browsing I discovered that the best way to do so is to create a static library (mylib.a) and then include it into other projects. I configure all projects to build into the a single build/ directory, and the lib creates two subfolders: debug/ and release/.

The dialog to "Add library" is broken and does not let me select a .a file, only a .lib file. I tried to manually add LIBS += -L"./" -l"lib.a" into the second project, with no luck (can't find the library).

It would be great if somebody can help me figure out project configuration. I don't really know what's going on.

Upvotes: 0

Views: 383

Answers (1)

john.pavan
john.pavan

Reputation: 950

I think what you need is a subdirs project in a separate directory. e.g. a directory structure that looks something like:

topLevel/
topLevel/myProject
topLevel/myLib

topLevel then has a .pro file that looks like:

TopLevel.pro
SUBDIRS += myProject
SUBDIRS += myLib

myProject has your current .pro file in its directory, and myLib has it's own .pro file. You may find this page useful.

Upvotes: 1

Related Questions