[Qbs] Depending on a library that is both shared and static

Uwe Salomon post at uwesalomon.de
Thu Feb 20 09:26:22 CET 2020


I've got a question regarding better control of the "Depends" item when
pulling a library that is built both shared and static.

For library projects that are to be packaged for Debian or Ubuntu, I find it
useful to set up the library's Product like this:

    DynamicLibrary {
      targetName: "mylibrary"
      type: ["dynamiclibrary", "staticlibrary"]
      Group {
        fileTagsFilter: ["dynamiclibrary", "dynamiclibrary_symlink", "staticlibrary"]
        qbs.install: true
        qbs.installdir: ...
This way, both the dynamic and the static library are built and installed
(in the staging directory), and can then be put into the Debian package --
the dynamic library into the "libmylibrary1" package, the static library
into the "libmylibrary-dev" package.

Problems arise, however, if one uses a Depends item in a Product in the
same Project for the library. This is necessary in the following cases:

1. a test executable that tests the library
2. some other executable that uses the library
3. another library that uses the library

Usually, one would like to link to the shared library for cases 2 and 3, and
for case 1 the decision depends on whether the test is a true blackbox test
(shared is fine) or a whitebox test (static often necessary).

However, Qbs always links to the static library in these cases. That's
problematic for several reasons.

Do you have any idea how I could control which version of the library is
being pulled into the consuming Product?


More information about the Qbs mailing list