From: Vladimir Prus (ghost_at_[hidden])
Date: 2003-12-29 08:55:21
> I've been happily using Boost.Build.V2 for quite a while now. Many
> thanks to Volodya, Dave, and everyone contributing to the project.
> The issue I have now is linkage errors with gcc. It is well known that
> gcc is peaky about order of the siurces on command line, the most
> generic libraries should appear at the end. For ages this problem was
> worked around in bjam by adding the whole set of libraries twice. It
> used to work just fine, but after one of recent changes I started
> getting link errors. Rearranging order of libraries on the command line
> fixes the errors, so it is not a bug in my setup. I am observing this
> behaviour on cygwin with most recent cygwin gcc (3.3.1).
> Any ideas what could be done to workaround/fix the problem? Maybe it is
> time to implement smarter generation of command line? Since build system
> knows the dependency tree, it should be possible to put libraries in
> correct order. I have no idea how hard it is though..
I think it's what's requested by
The problem can be split in two parts: finding order dependencies, and
reordering the libraries. The first one can be accomplished by assuming that
if you have
lib a : a.cpp other_lib : <use>yet_another_lib ;
Then 'a' should be present on the command line before 'other_lib' and
'yet_another_lib'. And current V2 records all those libraries. I think this
should be enough.
The second part requires writing an algorithm for ordering but it should not
be too hard.
> After googling around for a while I found another solution, add -Wl,"-("
> in the beginning of the list of libraries and -Wl,"-)" at the end. This
> will make linker to repeatedly scan a group of libraries between the -(
> and -) marks. Not sure what versions of linker support groups though.
> Please find attached a trivial patch implementing grouping.
Hmm... ld manual says this switch can considerable slow down linking. Do you
observe any such effect? This solution is easier, so if it has no drawbacks,
we can use it instead of writing some code.
Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk