I have included the header netdb.h
, where getaddrinfo
is included, but gcc issues this warning:
warning: Using \'getaddrinfo\' in s
I think certain features are dependent on the dynamic loader to work things out at run time. static linking is no longer practical unfortunately http://people.redhat.com/drepper/no_static_linking.html
I found a solution: you can use musl library to replace glibc. To use musl, you can either install it and build your software using musl-gcc, or you can use a Linux distribution that uses musl, e.g. Alpine Linux.
In my case, to save time, I chose Alpine Linux to build my program (https://github.com/zhanxw/rvtests), as I don't want to build multiple compilers (gcc, g++ and gfortran).
glibc uses libnss to support a number of different providers for address resolution services. Unfortunately, you cannot statically link libnss, as exactly what providers it loads depends on the local system's configuration.