• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: C++11 headers missing in /usr/include
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C++11 headers missing in /usr/include


  • Subject: Re: C++11 headers missing in /usr/include
  • From: Chris Cleeland <email@hidden>
  • Date: Sat, 21 Jan 2017 21:27:54 -0600

You can get the compiler to tell you its search paths pretty easily.

$ touch /tmp/a.cxx

$ clang -std=c++11 -v /tmp/a.cxx 

Apple LLVM version 7.0.2 (clang-700.1.81)

Target: x86_64-apple-darwin14.5.0

Thread model: posix

 "/Library/Developer/CommandLineTools/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.10.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name a.cxx -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 253.9 -v -dwarf-column-info -resource-dir /Library/Developer/CommandLineTools/usr/bin/../lib/clang/7.0.2 -stdlib=libc++ -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /Volumes/Hardware IO Tools -ferror-limit 19 -fmessage-length 238 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.10.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/3r/ypbpyb9512j8c933tp_b5whm0000gn/T/a-0ad1fb.o -x c++ /tmp/a.cxx

clang -cc1 version 7.0.2 based upon LLVM 3.7.0svn default target x86_64-apple-darwin14.5.0

ignoring nonexistent directory "/usr/include/c++/v1"

#include "..." search starts here:

#include <...> search starts here:

 /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1

 /usr/local/include

 /Library/Developer/CommandLineTools/usr/bin/../lib/clang/7.0.2/include

 /Library/Developer/CommandLineTools/usr/include

 /usr/include

 /System/Library/Frameworks (framework directory)

 /Library/Frameworks (framework directory)

End of search list.

 "/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 -o a.out /var/folders/3r/ypbpyb9512j8c933tp_b5whm0000gn/T/a-0ad1fb.o -lSystem /Library/Developer/CommandLineTools/usr/bin/../lib/clang/7.0.2/lib/darwin/libclang_rt.osx.a

Undefined symbols for architecture x86_64:

  "_main", referenced from:

     implicit entry/start for main executable

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)



On Sat, Jan 21, 2017 at 4:06 PM, Matthew LeRoy <email@hidden> wrote:
>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

OK, problem solved — the libc++ headers are installed at /Library/Developer/CommandLineTools/usr/include/c++/v1.

The reason I appeared so insistent that they be installed to /usr/include, is because of the fact that installing
the CLT package did cause a /usr/include folder to appear where there was none before, and it the C and C++ standard
library headers. Thus, I assumed that’s where the CLT package intended to install them — it just installed the
"wrong" ones, or so I thought, and I wanted to know how to get it to install the “right ones”.

I now realize that it actually installs them to /Library/Developer/CommandLineTools/…, and the ones installed to
/usr/include were a red herring. Of course some documentation for the CLT package would’ve avoided this whole manhunt
and discussion entirely.

Oh, and /Library/Developer/Toolchains/… is not a valid path, at least on my machine (as Jean-Daniel suggested).

Thanks all!

Matt

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: C++11 headers missing in /usr/include (From: Matthew LeRoy <email@hidden>)
 >Re: C++11 headers missing in /usr/include (From: Rich Siegel <email@hidden>)
 >Re: C++11 headers missing in /usr/include (From: Matthew LeRoy <email@hidden>)
 >Re: C++11 headers missing in /usr/include (From: Jens Alfke <email@hidden>)
 >Re: C++11 headers missing in /usr/include (From: Matthew LeRoy <email@hidden>)

  • Prev by Date: Re: C++11 headers missing in /usr/include
  • Next by Date: Re: Constraints to keep 2 views same height not working
  • Previous by thread: Re: C++11 headers missing in /usr/include
  • Next by thread: Re: C++11 headers missing in /usr/include
  • Index(es):
    • Date
    • Thread