Xcode 11.1:找不到 iostream' 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/58364711/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode 11.1: iostream' file not found
提问by yavvuz
I just updated my MacBook Proto macOS Catalina 10.15, and tried to compile and run a C++ command line program, but I had a problem which didn't exist on previous versions;
我刚刚将我的MacBook Pro更新到macOS Catalina 10.15,并尝试编译和运行C++ 命令行程序,但我遇到了以前版本不存在的问题;
This is simply the code:
这是简单的代码:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, World!\n";
return 0;
}
The code compiles and outputs the expected, but still the Xcode says:
代码编译并输出预期,但 Xcode 仍然说:
fatal error: 'iostream' file not found
I tried changing the Build Settings/C++ Standard Libraryto libstdc++, but a warning says:
我尝试将Build Settings/C++ Standard Library更改为libstdc++,但警告说:
warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead
And the same iostream error still exists.
并且仍然存在相同的 iostream 错误。
采纳答案by yavvuz
So, I restarted my laptop and everything seems to be fine right now, thanks for those who tried to help.
所以,我重新启动了我的笔记本电脑,现在一切似乎都很好,感谢那些试图提供帮助的人。
回答by bmg
I have the same issue, the code compiles and runs fine but XCode keeps saying iostream is not found. It seems like the error appears randomly so a reboot is only a temporary solution.
我有同样的问题,代码编译并运行良好,但 XCode 一直说找不到 iostream。该错误似乎是随机出现的,因此重新启动只是一个临时解决方案。
回答by Olubukola Ogunsola
In my case it won't even compile, after reading @Alan Birtles comment, I changed it to default and it works
在我的情况下,它甚至不会编译,在阅读@Alan Birtles 评论后,我将其更改为默认值并且可以正常工作
回答by dengApro
libstdc++
is not OK for Xcode Build & Compile time,
libstdc++
不适用于 Xcode 构建和编译时间,
libstdc++
is OK for iPhone Run Time
libstdc++
适用于 iPhone 运行时间
From answer recommended by @Alan Birtles
来自@Alan Birtles 推荐的答案
libstdc++
Support was removed from the iOS 12.0 Simulator runtime, but it remains in the iOS 12.0 (device) runtime for binary compatibility with shipping apps.
libstdc++
支持已从 iOS 12.0 Simulator 运行时中移除,但它仍保留在 iOS 12.0(设备)运行时中,以实现与交付应用程序的二进制兼容性。
I encountered this when declaration in .hpp
file.
我在.hpp
文件中声明时遇到了这个问题。
#include <iostream>
#include <string>
OK with
好的
#ifdef __cplusplus
#include <iostream>
#include <string>
// usage code
#endif