gethostname warning

Hi, does anyone knows how to get rid of this annoying warning? Thank you!

#include <netdb.h>
main()
{
    gethostbyname("test");
}

$ gcc -static test.c
/tmp/ccW9HG18.o: In function `main':
test.c:(.text+0x19): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

$ nm a.out | grep gethostbyname
0804f660 T __gethostbyname_r
0804f660 T __new_gethostbyname_r
080500b0 T __nscd_gethostbyname2_r
08050110 T __nscd_gethostbyname_r
0804f4a0 T gethostbyname
0804f660 W gethostbyname_r

-----

$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-targets=all --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu3)

gcc test.c

will stop the warning, but you will get others, your code is not correct - gethostbyname() returns a pointer to a hostent structure, for example.

I need a static link.

You have to redesign your code somehow.

gethostbyname() is not guaranteed to work internally the same way on different architectures. If you know the architecure ahead of time, then get the source for gethostbyname for that destination system, and embed it in your code. Otherwise, you will have to figure out what version of gethostbyname you have to run for the box your code is running on, then jump to that routine. ie., include all of your possible versions of the code.

gethostbyname is part of libc, so, for example, for a red hat box try:
libc/inet/