Reputation: 213228
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).
Upvotes: 4
Views: 1854
Reputation: 8349
Really a frustrating issue, especially for package maintennance.
Debian has built in support to patch libtool and fix this problem in debian packages
dh_autoreconf --as-needed
Or, if you're using CDBS:
include /usr/share/cdbs/1/rules/autoreconf.mk
DEB_DH_AUTORECONF_ARGS += --as-needed
Upvotes: 0
Reputation: 57854
You can fix it in Makefile.am
; basically it's the same as the answer to my question here, except you need to use -(no-)as-needed
instead of -(no-)whole-archive
.
Upvotes: 2
Reputation: 66
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
Upvotes: 5