shared libs

The gcc version is different on my computer than on the remote computer. An ldd on my program says:

Is there any way I can tell gcc to compile my program against my version of libc-2.7.so and ld-2.7.so (which I would provide along with the program) instead of the remote computer's libs ? (I do not have permissions to compile on the remote computer.)

How different? If it's just a minor version number then it might still be binary compatible with no special treatment.

If it's a major version number, then you'll probably need the headers themselves, not just the library, since the function definitions themselves may be different. Best bet is to simply compile it on the system you want it compiled for -- either that, or bring along the new libraries.

Or statically compile it on the original system, maybe.

=== SHARED ===
I have successfully linked ld-2.7.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-2.7.so. How can I do that ?

=== STATIC ===
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

How can I statically compile whatever file is missing ?

The static link is telling you, in so many words, that the runtime code does not exist in the .a file(s) used to make a static link - the archive does not have the entry point for the getaddrinfo() call.

afterthought - the kernel internals for the addr resolution are not identical, so the developers knew if they linked a static getaddrinfo for the wrong architecture it would crash.

You can manually create your own struct addrinfo - it is just that it is a pain in the butt, when compared to using getaddrinfo which is kind of auto-magic