[QBS] Linking inter-dependent libraries using gcc

Richard Weickelt richard at weickelt.de
Sun Aug 9 17:53:20 CEST 2015

> I'm trying to link inter-dependent libraries, but as qbs merges the list of
> libraries it seems to be impossible now.

I had a somehow related question some time ago [1] and created QBS-701 [2]
which You may want to support. It addresses the same procedure.

> For example there are two libraries: liba.a and libb.a. liba.a uses symbols
> from libb.a and libb.a uses symbols from liba.a. Then using gcc they must be
> linked with the following command line: "-la -lb -la". 

... or by the use of --start-group and --end-group [3]

> But I can't get this
> behavior using cpp.staticLibraries property, because qbs passes each library
> only once. So in such situation the only way is to use low level linkerFlags.

You could try an intermediate static library product with dependencies to
all Your external archives so that these are linked together into one
comprehensive archive. But I'm not sure, if the existing linker rules in QBS
would produce the desired result.

> Things become more complicated if one of this libraries is produced by qbs,
> while another one is an external library. I don't know how to workaround in
> such case without using qbs internals (artifact paths).

Again, could intermediate products help here?

> And finally two inter-dependent libraries built by qbs would produce graph
> cycle error.

Could You maybe solve A<--B<--A by splitting A into A1 and A2 (but pointing
to the same code) and B only depending on the headers of A1 whereas A2
depends on B?


[2] https://bugreports.qt.io/browse/QBS-701

More information about the Qbs mailing list