[Freeciv-Dev] [bug #20476] netdb.h conflict
URL: http://gna.org/bugs/?20476 Summary: netdb.h conflict Project: Freeciv Submitted by: hugo Submitted on: Sun 03 Feb 2013 01:04:36 PM GMT Category: general Severity: 2 - Minor Priority: 5 - Normal Status: None Assigned to: None Originator Email: Open/Closed: Open Release: Discussion Lock: Any Operating System: GNU/Linux Planned Release: ___ Details: After building against SVN @22265 on Ubuntu Ubuntu 10.04.4 LTS (Lucid), attempting to start the server immediately bailed out with the error Server: bad address: (none):5556. After some digging, this turned out to be a conflict between two different netdb.h files - /usr/include/netdb.h comes from libc6 (Ubuntu package libc-dev version 2.11.1-0ubuntu7.11 from the eglibc project), and includes a definition: # define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */ I also have /usr/include/bind/netdb.h, which comes from libbind (Ubuntu package libbind4, version 6.0-1, from the libbind project). This is the library that actually provides getaddrinfo(3), and does *not* define or support NUMERICSERV; attempting to pass ai_flags with 0x400 set always returns EAI_BADFLAGS. I don't know whether the error here is mine, Ubuntu's, Freeciv's, or that of one of the two source projects. 1) It was made harder to track down the problem because net_lookup_getaddrinfo in utility/netintf.c does not report or return the actual error. It would be useful if it could be modified to log the error, eg with: ... else { printf(getaddrinfo: error '%s' (%d)\n, gai_strerror(err), err); } 2) I do not know if the configure probes could be enhanced to check for both netdb.h and bind/netdb.h and make an intelligent choice between them. For now I've just hacked my netintf.c, which has got me a little further; I've not yet checked if I also need to change the other uses of netdb.h. 3) An alternative would be to support a build hint HAVE_AI_NUMERICSERV, but I suspect it will generally be hard for someone building freeciv to discover they should override this to false. Hope this helps, Hugo ___ Reply to this item at: http://gna.org/bugs/?20476 ___ Message sent via/by Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] [bug #20476] netdb.h conflict
Follow-up Comment #3, bug #20476 (project freeciv): Can you confirm if I got this right. Yes, header that is included is /usr/include/netdb.h which does define AI_NUMERICSERV. Meanwhile you can test if manually setting CPPFLAGS=-I/usr/include/bind for configure produces working build. It failed, this time on functions such as inet_ntoa, I think due to conflicts between arpa/inet.h and bind/arpa/inet.h - the latter redefines inet_ntoa to __inet_ntoa, but then __inet_ntoa can't be found at link time. I tried instead going the other way, to try to convince configure that I didn't need libbind at all: % svn diff configure.ac Index: configure.ac === --- configure.ac(revision 22316) +++ configure.ac(working copy) @@ -1012,8 +1012,11 @@ if test x$server = xyes; then SERVER_LIBS=-lm ${SERVER_LIBS} -dnl Some systems (e.g., BeOS) need this lib -AC_CHECK_LIB(bind, gethostbyaddr, SERVER_LIBS=-lbind $SERVER_LIBS) +dnl Some systems (e.g., BeOS) need -lbind, while others can better avoid it +AC_CHECK_FUNCS([gethostbyaddr]) +if test $ac_cv_func_gethostbyaddr = no; then + AC_CHECK_LIB(bind, gethostbyaddr, SERVER_LIBS=-lbind $SERVER_LIBS) +fi dnl Readline library and header files. FC_HAS_READLINE() With that change, -lbind is no longer included in LIBS or SERVER_LIBS; for some reason it is still included in GUI_sdl_LIBS, and I wasn't able to find what introduces it there. But I can build successfully with --enable-client=gtk2 (previously gtk2,sdl), start a server and a client and have them talk to each other. I suspect that the libbind4 package is my main problem, and I plan to remove it (but I'll wait in case there's more you'd like me to test); I believe that on this OS libc contains everything I'm likely to need from libbind, and quite likely in more modern and featureful fashion. Here's my full configure invocation now: ./configure --prefix=/opt/freeciv --enable-fcdb=mysql --enable-client=gtk2 --enable-svnrev --enable-aimodules=yes --disable-nls --enable-debug=some --with-readline --with-x --enable-shared --disable-ipv6 Hugo ___ Reply to this item at: http://gna.org/bugs/?20476 ___ Message sent via/by Gna! http://gna.org/ ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev