How to fix “fatal error: 'iostream' file not found” after upgrading to Xcode 10.1

*爱你&永不变心* 提交于 2020-05-28 12:02:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!