问题
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.
回答1:
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>
来源:https://stackoverflow.com/questions/55424137/how-to-fix-fatal-error-iostream-file-not-found-after-upgrading-to-xcode-10