升级到Xcode 10.1后如何修复"fatal error: 'iostream' file not found"

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

本文关键字:Xcode iostream file found not error 何修复 fatal      更新时间:2023-10-16

这个错误只是在更新Xcode(以及MacOS Mojave 10.14(后才出现。类似的事情也发生在#include <Python>,我改用 #include"python2.7/Python.h"来修复。

在 Clang 看不到基本标头中讨论了类似的错误。当我尝试时

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++很陌生。

编辑:括号内的间距。

如果您仔细阅读错误消息,您将看到它显示"在命令行上传递-std=libc++"。如果你重新阅读你实际写的东西,它说-stdlib=libc++.删除您那里的额外lib,它应该可以正常工作。

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