cctask explicitly specifies whether libraries are
static or dynamic by default. (Why does it need to do
this, btw? Doesn't the linker do this automatically?
cc task doesn't have any info the linker doesn't have,
by default.) It also explicitly specifies the stdc++
library by default (which is only necessary because Bug
#703279 has not been fixed. If cctask used g++ to link
when told to, this wouldn't be necessary).
Any if the user specifies a static library last, this
happens:
gcc -o a.out main.o -L/mylibs -Wl,-Bdynamic
-lmydynamiclib -Wl,-Bstatic -lmystaticlib -lstdc++
What happens is that the entire stdc++ library then
gets linked in statically.
This bug would ideally be fixed by fixing Bug #703279,
so the -lstdc++ wouldn't be necessary at all.
Otherwise, it should at least force a -Wl,-Bdynamic
before the -lstdc++.
The workaround is to make sure to always include a
dynamic library last. By switching the order of the
two libraries above, I could circumvent the problem,
but that's not always possible if you have only static
libraries to include.
Logged In: YES
user_id=27193
Several good points, using g++ on link (when appropriate is long
overdue). There is a need to allow the use to specify whether to use
"shared" or "static" libraries when both are available.
Should probably add a type attribute to libset:
<libset libs="foo" type="shared | static |dylib | any"/>
And then add -Wl,static or similar anyplace there is a switch between
types.