Skip to content

Instantly share code, notes, and snippets.

@sampsyo
Last active August 29, 2015 14:05
Show Gist options
  • Save sampsyo/cd5a24d1158b14a83ef1 to your computer and use it in GitHub Desktop.
Save sampsyo/cd5a24d1158b14a83ef1 to your computer and use it in GitHub Desktop.
Clang search path bug on OS X

I ran into a problem on OS X where a Clang I compiled myself couldn't find standard C++ includes (e.g., #include <iostream>) that the system-provided Clang could find. Using -v, I found that the system Clang was searching in:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1

which actually has those files. My own Clang was saying, even when I passed it the right -resource-dir to point it at the toolchain:

ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1"

because the paths are slightly (include vs. lib). The reason seems to be that Clang had a bug that placed those include files in the wrong directory, and this was shipped in XCode 5. This bug was fixed, so now Clang looks in the "right" place, which is unfortunately wrong for the buggy system toolchain (see Apple's sources with the bug in place).

The only real solution is to patch up your include paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment