关于codeblocks 的程序中编译出现对于iostream, no such file or directory
2014-07-30 19:02
851 查看
当我们将.cpp 文件 误设为.c 文件的时候, 就会出现上述编译报错信息。
解决办法是删除这个文件, 重新建立.cpp文件。
另外,还有如下情况。
其实 <iostream.h>是c风格的,可用,但注意格式:
要么是:
#include <iostream>
using namespace std;
要么是:
#include <iostream.h>
注意,这时是不能用using namespace std;这句话的,否则会出现你遇到的问题.
在标准C++里面,是不用#include <iostream.h>这种形式了,而要使用#include <iostream>
在VC6是在C++标准出来前发布的,所以它可以使用#include <iostream.h>这形式.
===注:如果在VS中VC的include文件夹中iostream文件不是.h的扩展名,最好是用第一种形式
另外在code::blocks, 我设置的编译器是gc++
解决办法是删除这个文件, 重新建立.cpp文件。
另外,还有如下情况。
其实 <iostream.h>是c风格的,可用,但注意格式:
要么是:
#include <iostream>
using namespace std;
要么是:
#include <iostream.h>
注意,这时是不能用using namespace std;这句话的,否则会出现你遇到的问题.
在标准C++里面,是不用#include <iostream.h>这种形式了,而要使用#include <iostream>
在VC6是在C++标准出来前发布的,所以它可以使用#include <iostream.h>这形式.
===注:如果在VS中VC的include文件夹中iostream文件不是.h的扩展名,最好是用第一种形式
另外在code::blocks, 我设置的编译器是gc++
gcc error - "iostream: No such file or directory"
[cpp] view
plaincopy
#include <iostream>
using namespace std;
int main(void)
{
cout<<"Hello World!\n";
return 0;
}
使用命令
gcc -o test test.c
test.c:1:20: iostream: No such file or directory
杯具啊,gcc是c的编译器,g++才有c++的iostream
参考:http://www.linuxquestions.org/questions/linux-software-2/gcc-error-iostream-no-such-file-or-directory-641330/
-------------------------------------------------------------------------
错误2:
undefined reference to `std::cout'等错误
原因
(1)gcc和g++都是GNU(组织)的一个编译器。
(2)后缀名为.c的程序和.cpp的程序g++都会当成是c++的源程序来处理。而gcc不然,gcc会把.c的程序处理成c程序。
(3)对于.cpp的程序,编译可以用gcc/g++,而链接可以用g++或者gcc -lstdc++。
总之,老拿gcc编程c++起来了。。。
相关文章推荐
- VS2008中编译C工程出现无法打开包括文件:“iostream.h”: No such file or directory
- VS2008中编译C工程出现无法打开包括文件:“iostream.h”: No such file or directory
- Cygwin中用NDK来编译程序出现"No such file or directory"问题
- C++编译出现iostream no such file or directory的原因
- 在编译CUDA程序时出现 fatal error C1083: 无法打开包括文件:“cutil.h”: No such file or directory 的问题
- 关于LINUX运行交叉编译工具链后编译时出现No such file or directory
- 引用原因.NET下编译C++代码时出现fatal error C1083: 无法打开包含文件:“iostream.h”: No such file or directory错误的解决方法.
- Ubuntu下QT程序中编译时出现speex/speex.h: No such file or directory
- .NET下编译C++代码时出现fatal error C1083: 无法打开包含文件:“iostream.h”: No such file or directory错误的解决方法.
- 项目文件.NET下编译C++代码时出现fatal error C1083: 无法打开包括文件:“xuhk_JNIHelloWorld.h”: No such file or directory错误的解决方法。
- VC编译程序时Cannot open precompiled header file: 'Debug/.pch': No such file or directory错误处理
- 在Linux下生成GUID的程序,及编译错误 “uuid/uuid.h: No such file or directory” 的解决办法。
- Gcc 4.6 编译 Linux kernel时出现错误error: elf_i386: No such file or directory
- Erlang 编译时出现"no such file or directory" 与 当前工作目录问题
- QT编译出现fatal error: QApplication: No such file or directory
- 编译Linux内核时出现“fatal error: linux/netfilter/xt_dscp: No such file or directory”
- .NET下编译C++代码时出现fatal error C1083: 无法打开包括文件:“xuhk_JNIHelloWorld.h”: No such file or directory错误的解决方法。
- BUG:给Nexus7编译Android4.2的时候出现 fatal error: map: No such file or directory
- VC编译程序时Cannot open precompiled header file: 'Debug/.pch': No such file or directory为什么
- 关于运行程序时 No such file or directory 的问题