Reputation: 14869
On OSX 10.9 I had installed a variety of header libraries under
/usr/include
/usr/local/include
And everything worked fine. Today I did the "free upgrade" to Yosemite, and suddenly everything stopped working. Together with Yosemite, I also (previously) upgraded Xcode (note, I am not compiling using Xcode, but clang directly via command line).
I have a CMakeLists.txt which clearly includes /usr/include
set(INCLUDE_HEADERS ${INCLUDE_HEADERS}
/usr/include
/usr/local/include)
include_directories(SYSTEM ${INCLUDE_HEADERS})
Yet, when I try to compile, I instantly get:
fatal error: 'boost/lexical_cast.hpp' file not found
#include <boost/lexical_cast.hpp>
What's going on here? Anyone else experience this, or even know how to solve it? Things were working fine in 10.9 (oh why did I upgrade?) I may also be doing something wrong as I noticed that cmake was upgraded to 3.0.2
Upvotes: 3
Views: 1481
Reputation: 670
Canonical way for such situations is:
find_package(boost REQUIRED)
if(Boost_FOUND)
include_directories(${boost_INCLUDE_DIRS})
endif()
It will add path to the BOOST header into compiler search path.
Upvotes: 2
Reputation: 14869
I found the problem and a solution. Problem is that by default, clang appears to search only in the SDK folder of the platform:
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk
This didn't use to happen before, or I had somehow changed without knowing.
So, I changed my .bash_profile
in my home dir, and added:
export C_INCLUDE_PATH=/usr/include:/usr/local/include
export CPLUS_INCLUDE_PATH=/usr/include:/usr/local/include
Close and reopen a new terminal, and now clang finds the include dirs, and works fine. Although I'm troubled by the fact that only the latter (/usr/local/include) appears to be used with the -I flag.
Upvotes: 3