gcc: link to a different libc file
I want to supply the shared libs along with my program rather than using the target system's due to version differences:
ldd says my program uses these shared libs: linux-gate.so.1 => (0xf7ef0000)(made by kernel) libc.so.6 => /lib32/libc.so.6 (0xf7d88000)(libc-2.7.so) /lib/ld-linux.so.2 (0xf7ef1000)(ld-2.7.so) I have successfully linked ld-xxx.so by compiling like this: gcc -std=c99 -D_POSIX_C_SOURCE=200112L -O2 -m32 -s -Wl,-dynamic-linker,ld-2.7.so myprogram.c But I have not managed to successfuly link libc-xxx.so. How can I do that ? |
Quote:
From GCC(1): Code:
-nostdlib |
Quote:
gcc -std=c99 -D_POSIX_C_SOURCE=200112L -O2 -m32 -s -Wl,-dynamic-linker,ld-2.7.so -L. -lc-2.7 -nostdlib -lgcc pig.c but it returns: /usr/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000008048ad0 Quote:
All I want is to run my program in a very old CentOS but my program in compiled in modern Debian. A much easier solution would be to simply compile my program in CentOS but I do not have permission to do this. So, I was thinking of making my program use the libc and ld files of Debian instead of the ones provided by CentOS. Is this not possible ? |
Maybe I missing something here... but if you are so concerned about portability that you are willing to install your own standard libs, why don't you just do static linking only, and compile everything directly into the binary?
|
Quote:
I have included the header netdb.h, where getaddrinfo is included, but gcc issues this warning: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking gcc -m32 -static -s -O2 -std=c99 -D_POSIX_C_SOURCE=200112L myprogram.c |
Quote:
Code:
/sbin/ldconfig -p | grep libc.so.6 Code:
libc.so.6 (libc6,x86-64, OS ABI: Linux 2.6.18) => /lib64/libc.so.6 In this case your only option - install same ancient centos somewhere (let say in VM), build your program there and copy it to the "production" centos If kernel version on your CentOS is >= than MINIMAL OS ABI version in your debian you have following options: 1. Same as above - create VM with a same centos and build there. 2. Build your program on debian as usual, without any tricks and then use Ermine - http://magicErmine.com or statifier - http://statifier.sf.net to create from your dynamically linked executable self-contained one. Statifier is licensed under GPL, Ermine is commercial. On the other hand Ermine works better than statifier on systems with memory randomization. |
All times are GMT -5. The time now is 04:10 PM. |