[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Shared libraries
- From: Jay Carlson <nop@...>
- Date: Wed, 14 May 2014 09:04:59 -0400
[I hadn't meant to hit send yet on that previous message of mine. I feel fortunate it was down to a couple typos and an incomplete thought by the time it went out.]
On May 14, 2014, at 3:05 AM, Coroutines <coroutines@gmail.com> wrote:
> This whole thread seems strange to me. I don't see why static builds
> of a library would be a problem for packagers/maintainers... you can
> build a -shared version of a library from a static library, but not
> the other way around.
$ cat foo.c
#include <time.h>
int now(void) { return (int)clock(); }
$ gcc -c foo.c
$ ar cru libfoo.a foo.o
$ gcc -shared -Wl,-whole-archive libfoo.a -Wl,-no-whole-archive -o libfoo.so
/usr/bin/ld: libfoo.a(foo.o): relocation R_X86_64_PC32 against undefined symbol `clock@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
$
Unless you mean "why do distros hate linking with static libraries". Lots of reasons, but the biggest is that when a security-sensitive bug is found in something like zlib or libpng, any packages linking those libraries statically have to be rebuilt from source and then delivered through the security patch channel.
Jay