Linking not working in homebrew's cmake since Mojave
I've isolated this to the following change in the VERBOSE=1 make
logs...
- High Sierra (<=10.13) and below did NOT use the
-isysroot
command. - Mojave (>=10.14) DOES use the
-isysroot
command.
From gnu.org:
-isysroot <dir>
This option is like the--sysroot
option, but applies only to header files (except for Darwin targets, where it applies to both header files and libraries). See the--sysroot
option for more information.
So this flag specifically clobbers the lib
search path only on Apple. This results in the compilation never looking in the standard ld
locations, which can be seen by typing ld -v dummy
.
Library search paths:
/usr/lib
/usr/local/lib
Why does cmake
do this? My thought is it was to fix the /usr/local/include
issues introduced with the new Mojave SDK behavior.
Unfortunately, I can't find a cmake
compile flag to add the default library search paths back in. For now the only solution I've found is to add the following to my project:
IF(APPLE)
# Fix linking on 10.14+. See https://stackoverflow.com/questions/54068035
LINK_DIRECTORIES(/usr/local/lib)
ENDIF()
I'm not sure if this is a behavior that warrants an upstream cmake
patch. If there is a better solution, please provide it.
Can't link libraries for C++11 on MacOS Mojave
Specify that you want from boost. Here, you need "system":
find_package(Boost REQUIRED system)
Boost sets up variables to help after:
target_link_libraries(FinalProject ssl cpprestsdk::cpprest ${Boost_SYSTEM_LIBRARY})
Installed, just not linked
Looks like a permission issue. I would try doing this
chmod 755 /usr/local/lib/pkgconfig
This should make that available, then try
brew link valgrind
If that doesn't work I would try doing a check on it
brew doctor
How to fix homebrew permissions?
I was able to solve the problem by using chown
on the folder:
sudo chown -R "$USER":admin /usr/local
Also you'll (most probably) have to do the same on /Library/Caches/Homebrew
:
sudo chown -R "$USER":admin /Library/Caches/Homebrew
Apparently I had used sudo
before in a way that altered my folder permission on /usr/local
,
from here on forward all installations with brew have proven to be successful.
This answer comes courtesy of gitHub's homebrew issue tracker
Related Topics
Can You Really Have a Function/Method Without a Body But Just a Try/Catch Block
Copying Non-Rectangular Roi Opencv
How Does the Friend Keyword (Class/Function) Break Encapsulation in C++
How to Handle C++ Return Type Std::Vector<Int> in Python Ctypes
Factory Method Implementation - C++
Why There Are Three Unexpected Worker Threads When a Win32 Console Application Starts Up
What Does It Mean to Return a Reference
How to See the Output of the Visual C++ Preprocessor
Const and Non Const Template Specialization
Best Way to for C++ Types to Self Register in a List
Why Can't I Initialize a Variable-Sized Array
What Are the Advantages and Disadvantages of Implementing Classes in Header Files
Xcode 3.2.1 and C++ String Fails!
Error C1083: Cannot Open Include File: 'Stdafx.H'
What Is the Size of Float and Double in C and C++
Std::Thread::Join() Hangs If Called After Main() Exits When Using VS2012 Rc