18

I just updated from Yosemite to El Capitan and it has broken one of my C++ programs which was relying on Boost. Whenever I try to compile, I get these errors:

fatal error: 'boost/timer/timer.hpp' file not found
#include <boost/timer/timer.hpp>

fatal error: 'boost/program_options.hpp' file not found
#include "boost/program_options.hpp"

I've been compiling it with the correct flags and it worked perfectly before:

-lboost_timer-mt \
-lboost_program_options-mt \

I've followed the home-brew instructions to chown /usr/local, run brew doctor and brew update, even brew reinstall boost. I've also checked and timer.hpp is present in /usr/local/include/boost.

Update Ran: clang++ -E -x c++ - -v < /dev/null

Apple LLVM version 7.0.0 (clang-700.0.72) Target: x86_64-apple-darwin15.0.0 Thread model: posix  "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
    -cc1 -triple x86_64-apple-macosx10.11.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -E -disable-free -disable-llvm-verifier -main-file-name - -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 253.2 -v -dwarf-column-info -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.0
    -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
    -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /usr/local/lib -ferror-limit 19 -fmessage-length 272 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.11.0
    -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o - -x c++ - clang -cc1 version 7.0.0 based upon LLVM 3.7.0svn default target x86_64-apple-darwin15.0.0 ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/v1" ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/local/include" ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/Library/Frameworks"
    #include "..." search starts here:
    #include <...> search starts here:  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.0/include /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks (framework directory) End of search list.
    # 1 "<stdin>"
    # 1 "<built-in>" 1
    # 1 "<built-in>" 3
    # 332 "<built-in>" 3
    # 1 "<command line>" 1
    # 1 "<built-in>" 2
    # 1 "<stdin>" 2
Jack Simpson
  • 1,681
  • 3
  • 30
  • 54
  • Are you using the compiler that comes with Xcode or something installed with homebrew? Have you made sure it's the same compiler you were using before the update? – user657267 Oct 02 '15 at 00:47
  • I'm compiling with the clang compiler in /usr/bin/g++ which is what I was using before. – Jack Simpson Oct 02 '15 at 00:48
  • Check the include paths with `clang++ -E -x c++ - -v < /dev/null` – user657267 Oct 02 '15 at 00:50
  • 1
    Thanks user657267, I just ran it and updated the question with the output. I just noticed if I add `-I /usr/local/include ` and `-L /usr/local/lib` to my makefile then it seems to compile alright (but a lot of warnings from boost for things like `warning: unused typedef 'boost_concept_check261'` which I never had before. – Jack Simpson Oct 02 '15 at 00:56
  • I don't really understand why the update to El Capitan would cause g++ to forget the /usr/local include and lib directories. – Jack Simpson Oct 02 '15 at 01:01
  • I haven't updated to El Capitan yet but I updated the command line tools yesterday to 7.0.0, my clang include path still has `/usr/local/include`. I'll be updating to EC later today so I can also verify if that's what's causing the issue, unlikely as it seems. – user657267 Oct 02 '15 at 01:02
  • According to your verbose output, a lot of your include paths seem to be prefixed with some XCode paths? like `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/local/include` could these be symlinks that were broken by the update? – melak47 Oct 02 '15 at 01:10
  • hmm maybe El Capitan has added them during the update and forgot about the other directories? – Jack Simpson Oct 02 '15 at 01:21
  • 1
    @JackSimpson your comment about adding -I and -L parameters has helped me, you should consider adding that as an answer so it might help more people (and so I can upvote it). Thanks! – Renato Gama Nov 13 '15 at 14:01
  • Glad it helped! The accepted answer did solve the issue tho and meant I no longer had to add those extra parameters, but it was a handy workaround before I was pointed to the xcode-select command. – Jack Simpson Nov 13 '15 at 14:16
  • Just get it worked on OSX 10.11.5. My answer: http://stackoverflow.com/a/38087651/5411841 – Ken H Jun 28 '16 at 23:08

2 Answers2

20

You should install the Xcode Command Line tools with xcode-select --install to get a version of clang that searches /usr/local by default. Otherwise, you're using the versions provided by Xcode proper, which only search the OS X SDK paths. (/usr/bin/gcc and /usr/bin/g++ both invoke clang and are not actually versions of gcc.)

Tim Smith
  • 6,127
  • 1
  • 26
  • 32
  • 1
    Yeah, I've been hearing people report that upgrading to El Capitan removed their Command Line Tools installation, so you only would've had the full-Xcode versions at that point. – Tim Smith Oct 05 '15 at 15:32
0

I had the same problem when I upgraded to El Capitan. I solved this problem reinstalling Boost with brew.

If you don't have brew installed, you can install it with

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then, install boost

brew install boost
  • I did run a reinstall of boost but it couldn't find it for some reason since clang was no longer looking in my /usr/include and /usr/libs directories any more when I compiled. – Jack Simpson Oct 05 '15 at 01:07