首页 > 解决方案 > 升级到 Xcode 10.1 后如何修复“致命错误:找不到‘iostream’文件”

问题描述

自从更新 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++ 很陌生。

编辑:括号内的间距。

标签: c++includeiostreamclang++xcode10

解决方案


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

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


推荐阅读