mjd-lists-plug on Mon, 24 Feb 2003 11:50:31 -0500


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Testing a new glibc



gabriel rosenkoetter:
> On Tue, Feb 18, 2003 at 09:36:59PM -0500, mjd-lists-plug@plover.com wrote:
> > I recently built glibc-3.2 and installed it under /usr/local/glibc-3.2
> > instead of in the default place.  Now I want to try it out.  How can
> > I tell gcc to use the new libraries and include files instead of the
> > old ones?  Do I need to wrte a new specfile?
> 
> Setting LDFLAGS=-Wl,--rpath -Wl, and
> CPPFLAGS=-I ought to do it.

It seems not.  Something else seems to be wrong.

I think the problem might be that gcc is using the wrong dynamic
linker.  Here are some outputs:

        plover% gcc -v -Wl,--rpath,/usr/local/glibc-3.2/lib -I/usr/local/glibc-3.2/include -o hello hello.c
        Reading specs from /usr/local/lib/gcc-lib/i586-pc-linux-gnu/3.2/specs
        Configured with: /src/gcc-3.2/configure --enable-threads --enable-languages=c,c++,java,objc
        Thread model: posix
        gcc version 3.2
         /usr/local/lib/gcc-lib/i586-pc-linux-gnu/3.2/cc1 -lang-c -v -I/usr/local/glibc-3.2/include -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=0 -D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i586__ -D__tune_pentium__ hello.c -quiet -dumpbase hello.c -version -o /tmp/ccuYdlYi.s
        ignoring nonexistent directory "/usr/local/glibc-3.2/include"
        GNU CPP version 3.2 (cpplib) (i386 Linux/ELF)
        GNU C version 3.2 (i586-pc-linux-gnu)
                compiled by GNU C version 3.2.
        ignoring nonexistent directory "NONE/include"
        ignoring nonexistent directory "/usr/local/i586-pc-linux-gnu/include"
        #include "..." search starts here:
        #include <...> search starts here:
         /usr/local/include
         /usr/local/lib/gcc-lib/i586-pc-linux-gnu/3.2/include
         /usr/include
        End of search list.
         as --traditional-format -V -Qy -o /tmp/ccas9xdM.o /tmp/ccuYdlYi.s
        GNU assembler version 2.13.90.0.2 (i386-redhat-linux) using BFD version 2.13.90.0.2 20020802
         /usr/local/lib/gcc-lib/i586-pc-linux-gnu/3.2/collect2 -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o hello /usr/local/lib/gcc-lib/i586-pc-linux-gnu/3.2/../../../crt1.o /usr/local/lib/gcc-lib/i586-pc-linux-gnu/3.2/../../../crti.o /usr/local/lib/gcc-lib/i586-pc-linux-gnu/3.2/crtbegin.o -L/usr/local/lib/gcc-lib/i586-pc-linux-gnu/3.2 -L/usr/local/lib/gcc-lib/i586-pc-linux-gnu/3.2/../../.. --rpath /usr/local/glibc-3.2/lib /tmp/ccas9xdM.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /usr/local/lib/gcc-lib/i586-pc-linux-gnu/3.2/crtend.o /usr/local/lib/gcc-lib/i586-pc-linux-gnu/3.2/../../../crtn.o


Now I run ./hello:

        plover% ./hello
        ./hello: /lib/libc.so.6: version `GCC_3.0' not found (required by ./hello)

Now I'll tell it to use the new library:

        plover% LD_LIBRARY_PATH=/usr/local/glibc-2.3/lib ./hello
        ./hello: /lib/ld-linux.so.2: version `GLIBC_PRIVATE' not found (required by /usr/local/glibc-2.3/lib/libc.so.6)

OK, I'll tell it to use the new dynamic linker also:

        plover% LD_LIBRARY_PATH=/usr/local/glibc-2.3/lib /usr/local/glibc-2.3/lib/ld-linux.so.2  ./hello
        Hello, world.

Aha.

Now, I will rerun gcc manually.  

        plover% gcc -c hello.c

This next command is copied from the output of 'gcc -v' above, except
that I have changed the value of the '-dynamic-linker' option from
/lib/ld-linux.so.2 to /usr/local/glibc-2.3/lib/ld-linux.so.2:

       plover%  /usr/local/lib/gcc-lib/i586-pc-linux-gnu/3.2/collect2 -m elf_i386 -dynamic-linker /usr/local/glibc-2.3/lib/ld-linux.so.2 -o hello /usr/local/lib/gcc-lib/i586-pc-linux-gnu/3.2/../../../crt1.o /usr/local/lib/gcc-lib/i586-pc-linux-gnu/3.2/../../../crti.o /usr/local/lib/gcc-lib/i586-pc-linux-gnu/3.2/crtbegin.o -L/usr/local/lib/gcc-lib/i586-pc-linux-gnu/3.2 -L/usr/local/lib/gcc-lib/i586-pc-linux-gnu/3.2/../../.. hello.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /usr/local/lib/gcc-lib/i586-pc-linux-gnu/3.2/crtend.o /usr/local/lib/gcc-lib/i586-pc-linux-gnu/3.2/../../../crtn.o

Now this works:

        plover% LD_LIBRARY_PATH=/usr/local/glibc-2.3/lib  ./hello
        Hello, world.

So I'll try the short version:

        plover% gcc -o hello -Wl,-dynamic-linker,/usr/local/glibc-2.3/lib/ld-linux.so.2  hello.c
        plover% LD_LIBRARY_PATH=/usr/local/glibc-2.3/lib  ./hello
        Hello, world.

So now I'll try adding the --rpath option so that I don't have to
force LD_LIBRARY_PATH when I'm running the command:

        plover% gcc -o hello -Wl,-dynamic-linker,/usr/local/glibc-2.3/lib/ld-linux.so.2  -Wl,--rpath,/usr/local/glibc-2.3/lib/ hello.c

        /usr/local/lib/libc.so.6: undefined reference to `_dl_lazy@GLIBC_2.1.1'
        /usr/local/lib/libc.so.6: undefined reference to `_dl_dst_substitute@GLIBC_2.1.1'
        /usr/local/lib/libc.so.6: undefined reference to `_dl_out_of_memory@GLIBC_2.2'
        /usr/local/lib/libc.so.6: undefined reference to `_dl_relocate_object@GLIBC_2.0'
        ...
        /usr/local/lib/libc.so.6: undefined reference to `_dl_global_scope_alloc@GLIBC_2.1'
        collect2: ld returned 1 exit status

What's happening here?

I get the same results if I run collect2 manually with the indicated
arguments.

Any suggestions?

Is there an "understand everything about dynamic libraries" document somewhere?
_________________________________________________________________________
Philadelphia Linux Users Group        --       http://www.phillylinux.org
Announcements - http://lists.netisland.net/mailman/listinfo/plug-announce
General Discussion  --   http://lists.netisland.net/mailman/listinfo/plug