This is the mail archive of the
glibc-linux@ricardo.ecn.wfu.edu
mailing list for the glibc project.
Re: Linking against different glibc version?
- To: glibc-linux at ricardo dot ecn dot wfu dot edu
- Subject: Re: Linking against different glibc version?
- From: =?iso-8859-15?Q?Ga=EBl_Qu=E9ri?= <gqueri at mail dot dotcom dot fr>
- Date: Mon, 10 Apr 2000 17:57:53 +0200
- References: <011901bfa2e4$0634a5a0$e200a8c0@zoo.at>
- Reply-To: glibc-linux at ricardo dot ecn dot wfu dot edu
On Mon, Apr 10, 2000 at 01:57:56PM +0200, Roland Schwarz wrote:
> On my system I have installed glibc 2.1.1 (RedHat 6.1).
> I compiled library version glibc 2.0.7 and installed it
> in /usr/i386-mylib-linux.
>
> Now I want to tell the linker to link (dynamically) against that
> library.
> Flags in Makefile:
> LDFLAGS = -L /usr/i386-mylib-linux/lib
>
> The *Problem* is that the linker apparently uses the
> /lib/ld-linux.so.2 dyna linker instead of
> /usr/i386-mylib-linux/lib/ld-linux.so.2 resulting in the error:
> undefined references to:
> _dl_object_relocation_scope
> _dl_global_scope_end
> _dl_default_scope
>
> I then tried to give the linker the switch
> --dynamic-loader /usr/i386-mylib-linux/lib/ld-linux.so.2
> but this did not help.
>
> Any ideas?
> Roland
For that you must use -Wl,-rpath-link
Don't use -Wl,--dynamic-linker because it will just encode the path of
the dynamic linker in the binary, and you will need to have the dynamic
linker at the same place when you run the binary.
in your case you can use
LDFLAGS = -B/usr/i386-mylib-linux/lib/ -Wl,-rpath-link,/usr/i386-mylib-linux/lib
the -B is for locating the crt?.o files at the right place
Also you must use the libc_nonshared.o from glibc-2.1 because glibc-2.0
will use libc.a after libc.so and ld will take the dl_* symbols from it
which won't work, so you'll have to edit /usr/i386-mylib-linux/lib/libc.so
and replace the GROUP command by
GROUP ( /usr/i386-mylib-linux/lib/libc.so.6 /usr/lib/libc_nonshared.a )
It is safe to use libc_nonshared.a from glibc-2.1 with glibc-2.0.
If you're really paranoid you can extract *stat.o from libc.a and
put that into a libc_nonshared.a...
With that you should have binaries which will work on glibc-2.0 systems;
as you see it's not so complicated...
Oh yes... you obviously have to use the headers from glibc-2.0
so you have to set CPPFLAGS with something like
CPPFLAGS = -nostdinc -I`gcc --print-file-name=include` -I/usr/i386-mylib-linux/include
Maybe there should be an entry in the FAQ about that (but it's certainly
a bit late...)
regards, gael