This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Linking against different glibc version?

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/ dyna linker instead of
> /usr/i386-mylib-linux/lib/ 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/
> 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 and ld will take the dl_* symbols from it
which won't work, so you'll have to edit /usr/i386-mylib-linux/lib/
and replace the GROUP command by

GROUP ( /usr/i386-mylib-linux/lib/ /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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]