Linking


Note from my own debugging of a autotools configure script:

+ echo "LIBRARY_PATH=$(brew --prefix)/lib${LIBRARY_PATH:+:${LIBRARY_PATH}}" >> $GITHUB_ENV

Set macOS LIBRARY_PATH for Homebrew

Per the macOS ld(1) man page https://www.unix.com/man-page/OSX/1/ld/,

The default library search path is /usr/lib then /usr/local/lib.

When HOMEBREW_PREFIX=/usr/local, this is where the .dylib files for X11 are symlinked by Homebrew.

When AC_PATH_XTRA is called, it uses /usr/bin/gcc (Apple clang) and since the libraries are found in /usr/local/lib, it does not need to specify any -L paths.

However when libtool is used to call Homebrew gfortran, it sets the flag -syslibroot which per the man page for ld(1):

The -syslibroot option will prepend a prefix to all search paths.

and this means that it no longer looks under /usr/local/lib by default. To fix this, add the default path back by setting the LIBRARY_PATH environment variable.


Package managers

Distribution

.dmg

Plist

Packages