0

When in my code i use gethostbyname for resolve hostname in a socket program and in the compilation i use -static, like this example

 gcc -o example -static -ggdb -mpreferred-stack-boundary=2 -fno-stack-protector -z execstack example.c

The compilation return me this warning

Warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

and when I execute it, the program return me "gethostbyname failed". How can i resolve this problem?

alk
  • 69,737
  • 10
  • 105
  • 255
Alex
  • 559
  • 1
  • 4
  • 6
  • If you would have google'd the warning you would have found [this](http://stackoverflow.com/a/15165424/1971013). It's the top search result! – meaning-matters Aug 08 '15 at 12:22
  • possible duplicate of [Compile a static binary which code there a function gethostbyname](http://stackoverflow.com/questions/15165306/compile-a-static-binary-which-code-there-a-function-gethostbyname) – meaning-matters Aug 08 '15 at 12:23

0 Answers0