On Tue, 2021-03-30 at 11:47 -0500, Peng Yu wrote:
> Hi,
> 
> crypt(3) does not need -lcrypt on macOS, but need -lcrypt on Linux.
> How does autoconf determine what library needs to be linked based on
> the source code? Thanks.
> 

AC_SEARCH_LIBS doesn't use the source code; instead it tries to link a
test program -- first with no libraries at all, and then with each of
the libraries you've suggested to it, in succession. So on macOS, it
would succeed without -lcrypt immediately. On linux, the first attempt
would fail, but the second attempt with -lcrypt would succeed. The
necessary -l<library> flags are then prepended to the $LIBS variable
for use in the build system.



Reply via email to