[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Help with static linking
Re: Help with static linking
Fri, 31 May 2013 08:31:03 -0500
K-9 Mail for Android
Statically linking libc is a recipe for disaster, so either read and
understand why, or just take my word for it.
I don't quite understand why you think you need the rest linked statically, BUT
the easiest way to do that would be to add LT_INIT to configure.ac to use
Libtool, and add --static-libtool-libs to the target's LDFLAGS.
That will cause all of the Libtool libraries to be linked statically when
If you are only targeting Linux desktop systems, png, gobject, gio, and glib
should already be there, and in most cases already in memory, so you will
benefit from zero additional memory use for the code pages. This also goes for
all the dependencies of these libraries. I'm not familiar with zzip, so if it
isn't a Libtool library you will have to make sure it is linked like this:
-Wl,-static -lzzip -Wl,call_shared
I don't have a computer in front of me, so YMMV, you should man ld to make sure
those flags are correct.
Kip Warner <address@hidden> wrote:
>Sorry for posting on both autoconf and automake lists. I wasn't sure
>which one would be more appropriate for this problem.
>I know this has come up before, judging by the archives, but I cannot
>figure out the best way to have my executable statically link against
>certain dependencies. This is needed because it executes off of optical
>media and I cannot always guarantee that the user's runtime environment
>will have the needed dependencies and shipping them shared would be a
>The dynamic dependencies, according to objdump, are the following...
> NEEDED libgio-2.0.so.0
> NEEDED libgobject-2.0.so.0
> NEEDED libglib-2.0.so.0
> NEEDED libzzip-0.so.13
> NEEDED libpng12.so.0
> NEEDED libstdc++.so.6
> NEEDED libm.so.6
> NEEDED libgcc_s.so.1
> NEEDED libpthread.so.0
> NEEDED libc.so.6
>libc, pthreads, the C++ runtime, etc., are safe to assume are
>but the rest I'd like to statically link against. Actually, I'd prefer
>to statically link against everything that I can if possible. But the
>ones for certain I know I should be able to statically link against are
>at least libzzip and libpng.
>I know there a number of different approaches to doing this, but from
>the pieces scattered in various places, it was difficult to determine
>the most reliable and recommended approach. For instance, I've tried
>'myproduct_LDADD = $(LIBINTL) -static', but objdump still reports all
>the above dynamic dependencies, so maybe it's not doing what I thought
>it was suppose to do.
>This is my configure.ac:
>This is my Makefile.am:
>Any help appreciated.
>Kip Warner -- Software Engineer
>OpenPGP encrypted/signed mail preferred
>Autoconf mailing list
Sent from my Android phone with K-9 Mail. Please excuse my brevity.