升级到Xcode 10.1后如何解决“严重错误:找不到'iostream'文件”

时间:2019-03-29 19:11:19

标签: c++ include iostream clang++ xcode10

此错误仅在更新Xcode(以及更新到MacOS Mojave 10.14)之后才出现。 #include <Python>发生了类似的情况,我改用#include“ python2.7 / Python.h”进行了修复。

Clang doesn't see basic headers中讨论了类似的错误。当我尝试

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

我明白了

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

完整错误:

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

任何帮助将不胜感激;我对C ++很陌生。

编辑:括号内的空格。

1 个答案:

答案 0 :(得分:1)

如果您仔细阅读错误消息,您会看到它显示“在命令行上通过-std=libc++”。如果您重新阅读实际写的内容,则会显示-stdlib=libc++。删除那里多余的lib,它应该可以正常工作。

此外,正如其他人对您的帖子发表的评论一样,您应该删除包含指令中的空格:#include <iostream>