[QBS] Linking inter-dependent libraries using gcc

Ilya Lyubimov villytiger at gmail.com
Mon Aug 10 11:16:45 CEST 2015


2015-08-09 18:53 GMT+03:00 Richard Weickelt <richard at weickelt.de>:

> > 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.
>

Thanks for the links. I think whole-archive isn't completely the same
option as start/end-group, but in my particular case it would really solve
the problem.

>
> > 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.
>

Unfortunately current static library linker rule just sets
cpp.staticLibraries property for the output artifact. So again I would get
each library specified once in linker options.

>
> > 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?
>

This case is what I have in my project. I could solve this by writing a
rule for merging two libraries by hand. But I think qbs must provide
built-in tool for this.

>
> > 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?
>

Indeed this case could be solved by reorganizing source code. But qbs may
provide some tool for this case too.

>
> Richard
>
>
> [1]
> http://lists.qt-project.org/pipermail/qbs/2014-November/001052.html
> [2] https://bugreports.qt.io/browse/QBS-701
> [3]
>
> http://stackoverflow.com/questions/5651869/gcc-what-are-the-start-group-and-end-group-command-line-options
> _______________________________________________
> QBS mailing list
> QBS at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qbs
>



-- 
С уважением, / Best regards
Любимов Илья / Ilya Lyubimov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20150810/8833e742/attachment.html>


More information about the Qbs mailing list