I don't know the right way to fix this, but something is definitely broken; and something needs to be fixed, one way or the other. The question is what exactly needs to be fixed.
Consider something like this:
LIBS="-lresolv $LIBS" AC_TRY_LINK_FUNC(res_query, AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
Here's what happens on x86_64:
gcc -o conftest -g -O2 -Wall -I.. -I./.. conftest.c -lresolv >&5 /tmp/ccW7EeDX.o(.text+0x7): In function `main': /home/mrsam/src/courier/authlib/configure:5160: undefined reference to `res_query' collect2: ld returned 1 exit status configure:5147: $? = 1 configure: failed program was:
[ blah blah blah ]
| /* We use char because int might match the return type of a gcc2 | builtin and then its argument prototype would still apply. */ | char res_query (); | int | main () | { | res_query (); | ; | return 0; | }
The same exact test on FC1 x86 will work.
The reason appears to be that you have to #include <resolv.conf> on x86_64 in order to succesfully pull res_query() out of libresolv.so. You don't need to do this on x86, and the test program generated by AC_TRY_LINK_FUNC does not include any headers, but uses a manual prototype.
So, what now?
Sam Varshavchik wrote:
I don't know the right way to fix this, but something is definitely
gcc -o conftest -g -O2 -Wall -I.. -I./.. conftest.c -lresolv >&5 /tmp/ccW7EeDX.o(.text+0x7): In function `main': /home/mrsam/src/courier/authlib/configure:5160: undefined reference to `res_query' collect2: ld returned 1 exit status configure:5147: $? = 1 configure: failed program was:
[ blah blah blah ]
| /* We use char because int might match the return type of a gcc2 | builtin and then its argument prototype would still apply. */ | char res_query (); | int | main () | { | res_query (); | ; | return 0; | }
The same exact test on FC1 x86 will work.
Only for compatibility reasons. This is no supported interface of the resolver library. It is not exported for the ABIs which don't need it to be compatible with older releases. If a programmer things her/his code needs this interface an implementation must come with the program.
Sam Varshavchik napsal(a):
I don't know the right way to fix this, but something is definitely broken; and something needs to be fixed, one way or the other. The question is what exactly needs to be fixed.
LIBS="-lresolv $LIBS" AC_TRY_LINK_FUNC(res_query, AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
/tmp/ccW7EeDX.o(.text+0x7): In function `main': /home/mrsam/src/courier/authlib/configure:5160: undefined reference to `res_query'
The reason appears to be that you have to #include <resolv.conf> on x86_64 in order to succesfully pull res_query() out of libresolv.so. You don't need to do this on x86, and the test program generated by AC_TRY_LINK_FUNC does not include any headers, but uses a manual prototype.
So, what now?
Fetchmail uses this (after checking for the presence of the necessary header files):
| AC_LINK_IFELSE([AC_LANG_PROGRAM([[ | #include <sys/types.h> | #ifdef HAVE_NETINET_IN_H | #include <netinet/in.h> | #endif | #ifdef HAVE_ARPA_NAMESER_H | #include <arpa/nameser.h> | #endif | #ifdef HAVE_RESOLV_H | #include <resolv.h> | #endif | extern int res_search(); | ]], [[res_search(0, 0, 0, 0, 0);]])], | [AC_MSG_RESULT([found]) | AC_DEFINE(HAVE_RES_SEARCH, [1], | [Define to 1 if you have the 'res_search' function.]) | break], [AC_MSG_RESULT([not found])])
Mirek
Hello,
On Tue, Sep 26, 2006 at 07:04:55AM +0200, Miloslav Trmac wrote:
Sam Varshavchik napsal(a):
LIBS="-lresolv $LIBS" AC_TRY_LINK_FUNC(res_query, AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
/tmp/ccW7EeDX.o(.text+0x7): In function `main': /home/mrsam/src/courier/authlib/configure:5160: undefined reference to `res_query'
The reason appears to be that you have to #include <resolv.conf> on x86_64 in order to succesfully pull res_query() out of libresolv.so.
well, using resolv.h portably can be tricky. The glibc manpage says that you have to include netinet/in.h and arpa/nameser.h first. Moreover, on Solaris 9, you have to include netdb.h, too.
So to check for resolv.h correctly, you have to do this:
AC_CHECK_HEADERS(sys/types.h netinet/in.h arpa/nameser.h netdb.h resolv.h, [], [], [[#ifdef HAVE_SYS_TYPES_H # include <sys/types.h> #endif #ifdef HAVE_NETINET_IN_H # include <netinet/in.h> /* inet_ functions / structs */ #endif #ifdef HAVE_ARPA_NAMESER_H # include <arpa/nameser.h> /* DNS HEADER struct */ #endif #ifdef HAVE_NETDB_H # include <netdb.h> #endif]])
In Autoconf 2.60, the above code is available as AC_HEADER_RESOLV.
And this should be enough, because systems with resolv.h should also have an implementation. So my guess is that no further checking is needed, but I'm not an expert on systemology.
If there are really systems with resolv.h but without res_query, you might use a variation of what Miloslav Trmac posted (adding netdb.h).
But remeber that the goal of configure is to adapt the project to all possible Unix flavours, not to check for broken installations.
If there are further questions, the mailing list autoconf gnu org might also be a good place to discuss them.
Have a nice day, Stepan Kasal
devel@lists.stg.fedoraproject.org