1

This error has only appeared for me since updating Xcode (and to MacOS Mojave 10.14). Something similar happened with #include <Python>, which I fixed by instead using #include "python2.7/Python.h".

There is a similar error discussed in Clang doesn't see basic headers. When I try

clang++ -stdlib=libc++ PyTrans.cpp -o -v

I get

ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation).

The full error:

warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]

/Users/joe/Documents/Research/EkpPyTransportDist/PyTransport/PyTrans/PyTrans.cpp:20:10: fatal error: 'iostream' file not found include <iostream> ^~~~~~~~~~ 1 warning and 1 error generated. error: command 'gcc' failed with exit status 1

Any help would be greatly appreciated; I am very new to C++.

Edit: Spacing within brackets.

J. Wraga
  • 21
  • 1
  • 3
  • 1
    Get rid of the spaces in your include. Make it `#include ` It's actually looking for a " iostream " file meaning with a space before and after the iostream. – drescherjm Mar 29 '19 at 19:14
  • 1
    Having spaces inside include directive is erroneous. – Raindrop7 Mar 29 '19 at 19:17
  • I got this error because I tried to use `/usr/bin/cpp` instead of `/usr/bin/clang++` to compile a C++ file. – nisetama Aug 06 '22 at 09:16

1 Answers1

2

If you read the error message carefully, you'll see that it says "pass -std=libc++ on the command line." If you re-read what you actually wrote, it says -stdlib=libc++. Remove the extra lib you have in there and it should work just fine.

Also, as others have commented on your post, you should remove the spaces in your include directives: #include <iostream>

Will Eccles
  • 394
  • 1
  • 5
  • 15
  • Using `clang++ -stdlib=libc++ PyTrans.cpp -o -v` gives `error: invalid value 'libc++' in '-std=libc++'`, but then gives a few suggestions. I tried one of them, `clang++ -std=c++17 PyTrans.cpp -o -v`, which still gives the linker issue. And I did do the correct spacing within the brackets; I added the space when posting here since the word "iostream" would not appear otherwise. – J. Wraga Mar 29 '19 at 19:41
  • @J.Wraga Ah, sorry. I got those two flags mixed up. In that case, it sounds like something to do with your include path is messed up. I would consider reinstalling XCode or the command line utilities. Also, the `.o` flag is not useful on its own, though I doubt that that has anything to do with your error. I'm not sure I can help more than that, unfortunately :( – Will Eccles Mar 29 '19 at 23:06