ios 在 Xcode 中找不到 iostream
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13857805/
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
iostream not found in Xcode
提问by Adam Szeptycki
I have problem including ZXing in my App. I get error: "iostream file not found". I have done everything like in ZXing instruction but i can't get this working. I'm including this in .mm file. I use story boards this project is for iOS 6.0 This is error i get:
我的应用程序中包含 ZXing 时遇到问题。我收到错误:“找不到 iostream 文件”。我已经完成了 ZXing 指令中的所有操作,但无法正常工作。我将其包含在 .mm 文件中。我使用故事板这个项目适用于 iOS 6.0 这是我得到的错误:
In file included from /Users/adam/Developer/project/project/SecondViewController.mm:11: In file included from zxing/iphone/ZXingWidget/Classes/QRCodeReader.h:10: In file included from zxing/iphone/ZXingWidget/Classes/FormatReader.h:22: zxing/cpp/core/src/zxing/common/Counted.h:23:10: fatal error: 'iostream' file not found
在 /Users/adam/Developer/project/project/SecondViewController.mm 中包含的文件中:在 zxing/iphone/ZXingWidget/Classes/QRCodeReader.h 中包含的文件中:10 中:在 zxing/iphone/ZXingWidget/Classes 中包含的文件中/FormatReader.h:22: zxing/cpp/core/src/zxing/common/Counted.h:23:10: 致命错误: 'iostream' 文件未找到
Any idea what can i do to get this working?
知道我能做些什么来让它工作吗?
EDIT:
编辑:
When i select Compile Source File As Objcetive-C++ project comiples without issues, BUT as i was told this is not god soultion beacuse this can make some problems later on with other parts of app.
当我选择 Compile Source File As Objcetive-C++ project comiples 没有问题时,但正如我被告知这不是上帝的灵魂,因为这可能会在以后与应用程序的其他部分产生一些问题。
回答by Spawnrider
Just rename your implementation file with .mm extension instead of .m solve the issue.
只需使用 .mm 扩展名而不是 .m 重命名您的实现文件即可解决问题。
回答by muffe
Project -> Build Settings -> Apple LLVM compiler 4.1-Language -> C++ Standard Library
项目 -> 构建设置 -> Apple LLVM 编译器 4.1 语言 -> C++ 标准库
Make sure to set that to "libstdc++"
确保将其设置为“ libstdc++”
回答by corbinfiasco
Try to create a new project, and choose "command line tool" as the template for your project. Choose C++. Paste your code into the new project (it should be a .cpp file). When you run the program, it should be able to include iostream without any problems.
尝试创建一个新项目,并选择“命令行工具”作为您项目的模板。选择 C++。将您的代码粘贴到新项目中(它应该是一个 .cpp 文件)。当您运行该程序时,它应该能够毫无问题地包含 iostream。
回答by Steven Delrue
placing #import "QRCodeReader.h"
in the mm-file instead of it's header-file fixed the issue for me
放置#import "QRCodeReader.h"
在 mm 文件而不是头文件中为我解决了这个问题