Search code examples
c++linuxstatic-linkinggethostbyname

Floating point exception using function gethostbyname in static linked application


I have a code:

struct hostent *hp = gethostbyname(dns.c_str());

in my app. I compile it on Ubuntu server linking all statically. All ok, but when i try to start this app on CentOS i have a error in this gethostbyname calling:

Floating point exception

Can you help me how to fix that? Thanks!


Solution

  • static linking considered harmful http://www.akkadia.org/drepper/no_static_linking.html

    "all kinds of features in the libc (locale (through iconv), NSS, IDN, ...) require dynamic linking to load the appropriate external code."