autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Failure to use -lnsl on Solaris with AC_CHECK_LIB


From: Russ Allbery
Subject: Re: Failure to use -lnsl on Solaris with AC_CHECK_LIB
Date: Tue, 06 Sep 2005 11:56:21 -0700
User-agent: Gnus/5.110004 (No Gnus v0.4) XEmacs/21.4.17 (linux)

Stepan Kasal <address@hidden> writes:

> though I don't have real experience with handling this problems, I'd like
> to point out some inconsistencies:

> 1) Libraries should be _prepended_ to LIBS, not appended.

Not in this case.

> The reason is that for stsic libraries, the linker searches them only
> once, in the order given on the cmdline.  So the most specific ones have
> to be at the beginning.

Right, and socket and nsl don't depend on anything except each other on
those systems where they're needed, so they're properly placed at the end.

> 2) The call of AC_CHECK_LIB on the last line uses this library list:
>       -lnsl -lsocket $LIBS
> Again, this is because it thinks that libnsl is the "more specific" one,
> while libsocket is a lower-layer library needed by libnsl.

> I guess there is no need to argue which of the two is "more specific";
> I just want to point out that the test and the actual LIBS value should
> be consistent.

This is a valid point, but the existing code is tested on Unisys (which
has this particular issue) and I'm very reluctant to change it to
something that hasn't been tested, even if it looks more correct.

> Relying on your information that "-lsocket -lnsl" is the most common case,
> which is also consistent that you first call AC_SEARCH_LIBS for libnsl,
> I suggest this code:

> AC_SEARCH_LIBS([gethostbyname], [nsl])
> AC_SEARCH_LIBS([socket], [socket], [],
>     [AC_CHECK_LIB([socket], [socket],
>                 [LIBS="-lsocket -lnsl $LIBS"], [], [-lnsl])])

> Warren, will you please update the Autoconf Macro Archive?

Please don't.  The code works and is widely tested.  Please do not replace
it with something untested based on theoretical purity unless you're
actually going to test it on all the platforms the original was tested on.

-- 
Russ Allbery (address@hidden)             <http://www.eyrie.org/~eagle/>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]