How do I link a shared library with --as-needed using Automake? When I tried adding the flag to LDFLAGS, I saw libtool called as so:
/bin/bash ../../libtool --mode=link ... -Wl,--as-needed ... dependencies
Which results in a call to GCC like so:
gcc -shared ... dependencies ... -Wl,--as-needed ...
But that’s the wrong order.
-
Is there a way to do this with Libtool?
-
Or is there a nice way to build shared libraries using Automake but without Libtool? (I’ve been frustrated at Libtool for various other reasons in the past…)
It seems the Debian folks ran into this problem too (bug report) but I’d like to be able to fix this for my project rather than messing with my system (unless I misunderstand the fix).
You can fix that just for your project by modifying the ltmain.sh script in your project sources. You can even add it as part of autotools bootstrapping, as in:
https://meego.gitorious.org/tracker/tracker/commit/cf2ca3414aeba146dceacc5ecd84765f4c08a06f