I'm trying to link to my non-standard glibc on a Gentoo stable system. By "non-standard" I mean simply the latest glibc git clone, in the main branch.
I have built this in a separate build directory, no errors. I then make install it to a separate directory (specified by --prefix in the configure command).
My configure command is simply ./configure --prefix=/new_glibc
However, the problem is with the compilation/linking.
What is the correct command to compile and link? I've tried to follow several guides for this, including what appears to be the deprecated http://www.tldp.org/HOWTO/Glibc2-HOWTO-6.html (e.g. -b is no longer seems to be a valid argument).
I've also tried to follow: Building GCC with glibc in a non-standard location without root
~/ $ export LD_LIBRARY_PATH=/new_glibc
~/ $ gcc -nodefaultlibs -lgcc -I/new_glibc/include test.c
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/crt1.o: In function `_start':
(.text+0x12): undefined reference to `__libc_csu_fini'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/crt1.o: In function `_start':
(.text+0x19): undefined reference to `__libc_csu_init'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/crt1.o: In function `_start':
(.text+0x25): undefined reference to `__libc_start_main'
/tmp/ccWPNGYR.o: In function `main':
test.c:(.text+0x1e): undefined reference to `puts'
collect2: error: ld returned 1 exit status
I've also tried to only compile with -c and link manually:
$ ld -rpath=/new_glibc/lib test.o
ld: warning: cannot find entry symbol _start; defaulting to 00000000004000e8
test.o: In function `main':
test.c:(.text+0x1e): undefined reference to `puts'
I've also tried to debug this problem with LD_DEBUG=all, but this is very verbose and it is hard to interpret the debug messages. E.g. what does this mean (this is from a session where I do compilation and linking with gcc all in one command, i.e. without -c, using the aforementioned command)?
30508: file=libc.so.6 [0]; needed by gcc [0]
30508: find library=libc.so.6 [0]; searching
30508: search path=/new_glibc/tls/x86_64:/new_glibc/tls:/new_glibc/x86_64:/new_glibc (LD_LIBRARY_PATH)
30508: trying file=/new_glibc/tls/x86_64/libc.so.6
30508: trying file=/new_glibc/tls/libc.so.6
30508: trying file=/new_glibc/x86_64/libc.so.6
30508: trying file=/new_glibc/libc.so.6
30508: search cache=/etc/ld.so.cache
30508: trying file=/lib64/libc.so.6
30508:
30508: file=libc.so.6 [0]; generating link map
30508: dynamic: 0x00007fc1cfc15b40 base: 0x00007fc1cf872000 size: 0x00000000003a9c38
30508: entry: 0x00007fc1cf896d00 phdr: 0x00007fc1cf872040 phnum: 11
30508:
30508: checking for version `GLIBC_2.2.5' in file /lib64/libc.so.6 [0] required by file gcc [0]
30508: checking for version `GLIBC_2.3.4' in file /lib64/libc.so.6 [0] required by file gcc [0]
30508: checking for version `GLIBC_2.3' in file /lib64/ld-linux-x86-64.so.2 [0] required by file /lib64/libc.so.6 [0]
30508: checking for version `GLIBC_PRIVATE' in file /lib64/ld-linux-x86-64.so.2 [0] required by file /lib64/libc.so.6 [0]
It is obviously looking in the correct directory /new_glibc/ however I don't see it looking in /new_glibc/lib, which of course is where the actual library files it needs are.
In brief, what is the correct compilation command to make gcc compile using glibc under /new_glibc?