FYI, you can also use the ‘xcrun’ command-line tool to find the current SDK that will be used by /usr/bin/clang
xcrun --sdk macosx --show-sdk-path
Which, on my machine, returns:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
Inside you will find a usr folder with include, lib, etc.
You can also find the developer tools by doing something like:
xcrun --find clang
Which prints:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
As Jens mentioned, /user/bin/clang is a stub, which just calls xcrun to find and execute the default compiler tool. I’m guessing it probably does something equivalent to:
exec `xcrun --find clang`
Finally, as has been mentioned, if you don’t want to deal with the Macintosh SDK and want a more ‘Unix-like’ environment, download and install clang/llvm from a package. Headers/libs should then be in a more usual place, but will probably be in /usr/local/ since /usr/bin/ isn’t writable in the file system any more.
Doug Hill
On Jan 20, 2017, at 3:00 PM, Jens Alfke < email@hidden> wrote:
On Jan 20, 2017, at 12:24 PM, Matthew LeRoy < email@hidden> wrote:
So, am I doing something wrong? Does it seem odd that the Command Line Tools are installing the old libstdc++ headers and not the libc++ headers?
As others have said, don’t assume it’s a law of nature that headers have to be located in /usr/include. They don’t have to be there, and on Mac they usually aren't. I don’t even have a /usr/include directory on my system, and I do tons of development (command-line as well as Xcode) on it.
What you need to do is find where Clang is looking for header files. You can do that by opening a header in Xcode and then Command-clicking its filename in the top navigator strip to get a drop-down menu of the hierarchy, then selecting the enclosing directory. On my system the path is /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 Don’t be surprised that it’s inside Xcode; all the developer tools (including clang itself) are inside Xcode. /usr/bin/clang is just a tiny stub that finds and launches the real copy.
—Jens
|