[QBS] static library dependency always recompiles

arturo castro me at arturocastro.net
Wed Sep 30 12:57:17 CEST 2015

Yes i already have a module that exports all the search paths and other
flags common to the library and applications using it.

To explain better the use case, the library i develop has around 200
examples, every time a user wants to compile one the library has to be
compiled already otherwise having it as a dependency would recompile the
library every time.

That would be fine for most users but people developing the project
usually do modifications to the library itself while developing
applications so it's really handy that just by running the application
it'll recompile whatever has changed in the library too. Otherwise it's
really easy to run an application without having recompiled the library
first to find that the changes you've just done are not there, which can
become super confusing.

With every other ide we use (visual studio, codeblocks, xcode and plain
makefiles) we have the option to do this, qmake also allows to do this.

Indeed with qtcreator you can open a project and the library it depends
on, set one project to be dependent on another (through the projects >
dependencies view, not as a qbs dependency) and it'll do what i'm
expecting but as soon as i close the projects that setting is lost.

I guess i'm looking for something similar to a visual studio solution
where you can open several projects but all of them keep their settings
and recompile in their own place so if a library is a dependency to more
than one project once it's compiled it won't recompile in another
solution except for any change.

On 30.09.2015 12:33, Richard Weickelt wrote:
>> 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.
> _______________________________________________
> QBS mailing list
> QBS at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qbs

More information about the Qbs mailing list