Glibc warning concerning use of getaddrinfo() in static library
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Glibc warning concerning use of getaddrinfo() in static library
I am using a static library in which one of the modules employs the use of getaddrinfo().
When I link the library with an application, I get the following warning:
Code:
libSocket++.a(SocketUtility.o): In function `socketpp::FillAddress(int, char const*, unsigned short, sockaddr_in*)':
/home/whitneyd/Redirector/SocketLibrary-1.1.6/socket++/SocketUtility.cpp:114: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
Is there any way to prevent this warning from occurring? I've tried linking the static version of the C library (/usr/lib/libc.a, by specifying "-static -lc" as one of my linker options, but that did not work.
I think you posted about this elsewhere... the answer is that some glibc functions simply cannot be linked statically and still work. IF you want to use those functions you need to supply or depend on the shared libraries being present at runtime, or use some other libc to link against -I'm not sure, though, if newlib or uClibc will let you do this either.
If I had posted this topic before, I must have been inebriated, because I do not recall doing such.
Anyhow, I understand the cause of the warning, and your answer seems to confirm that. I was just wondering if there was a way to remove the warning, perhaps by statically linking the C library into the app. But it does not appear as if this is possible, nor when I think about it, be very practical.
Fortunately for me, I only use the SocketLibrary on Linux distros, so portability to other OSes is not a concern.
Sorry, I must be mistaken -but I just saw a posting yesterday about the same fucntion plus a couple of others.
If you are statically linking, it would be worth checking out newlib and/or uclibc as using them will provide much smaller binaries. uClibc, especially, claims to be better for staically-linking. newlib is less feature-full.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.