[QBS] static library dependency always recompiles

Richard Weickelt richard at weickelt.de
Wed Sep 30 12:33:44 CEST 2015

> I develop an open source library which i also use in my projects. I have
> created a qbs project for my applications that has the library's qbs as
> a dependency, using reference. The problem is that whenever i start a
> new application it recompiles the library completely.
> Instead of recompiling every time i create a new application i would
> like for the library to always compile in the same folder. So if i
> create a new project the library is already compiled. That way i don't
> end up with a lot of copies of the library's .o in every application
> that depends on it.

By "start a new application" you mean, "create a new application project in
a new folder"? What You observe, is the intended behaviour. AFAIK, you have
two options.

1) Create a single root project and define every application and Your
library as product within that project or reference them as sub projects.
When building the root project, every product is only built once.

2) Don't reference Your library within qbs as a project, but build it
separately and install it to some folder on Your system. In Your application
products You would then load it via cpp.staticLibraries and reference
necessary header files by cpp.includePaths

If Your library exports additional implications, like linker flags etc., You
might want to generate a custom qbs module for it as well. This serves as a
replacement for traditional pkg-config files. More infos about custom
modules: http://doc.qt.io/qbs/custom-modules.html
A (complicated) example are the Qt libaries. Maybe somebody can come up with
a much simpler example project.

For what I understand, these are the intended use cases of qbs.

More information about the Qbs mailing list