I've reproduced this symptom on two computers now, cmake
seems to no longer look in /usr/local/lib
(or more properly, $(brew --prefix)/lib
) for Homebrew-provided libraries since upgrading my machine to macOS Mojave.
Although there are ways to circumvent this (e.g. search for homebrew prefix using EXECUTE_PROCESS
; add the result to LINK_LIBRARIES(...)
command) none are ideal. What changed in Mojave to break this behavior?
The temporary workaround is to add the following to CMakeLists.txt
:
# WARNING: Don't hard-code this path
LINK_DIRECTORIES(/usr/local/lib)
I've already tried brew doctor
and updated all homebrew packages to no avail.
The specific error that cmake
(make
) shows is:
ld: library not found for -l<somelib>
I've asked the question on the Homebrew forums and the Apple developer forums.
ld -v 2
. On High Sierra, it lists/usr/local/lib
in the default linker path. Need to compare against Mojave. – Dungaree/usr/local/lib
in the default linker path. – DungareeVERBOSE=1
tomake
and comparing the exact linker flags between 10.13 and 10.14 was I able to track it down to a new-isysroot
flag being added. Here's a detailed discussion about it on MacPorts trac.macports.org/ticket/57612 – Dungaree