LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 884|回复: 3

求教在Mandrake下gcc的使用问题

[复制链接]
发表于 2003-5-2 06:33:53 | 显示全部楼层 |阅读模式
有谁在Mandrake 9下使用过gcc 编译程序的经验?
我安装了使用Mandrake 9 并使用gcc 编译一个C++的例子,但编译有错,我的C++程序如下:

#include <iostream.h>
int main()
{
cout<<"test\n\n";
return 0;
}
编译后显示:
[root@localhost tmp]# gcc test.cc
In file included from /usr/include/c++/3.2/backward/iostream.h:31,
                 from test.cc:1:
/usr/include/c++/3.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
/tmp/cc3HLE0n.o: In function `main':
/tmp/cc3HLE0n.o(.text+0x19): undefined reference to `std::cout'

不只到为什么会出这个问题?然后我将程序修改为:

#include <iostream>

int main()
{
cout<<"test\n\n";
return 0;
}

编译后显示:
[root@localhost tmp]# gcc test.cpp
test.cpp: In function `int main()':
test.cpp:5: `cout' undeclared (first use this function)
test.cpp:5: (Each undeclared identifier is reported only once for each function it appears in.)
[root@localhost tmp]#

是不是在Mandrake 9下gcc不支持这种标准的C++程序?

请指点迷经。

谢谢。
发表于 2003-5-2 09:24:20 | 显示全部楼层
编译cpp的相应命令是g++,gcc是专门编译c代码的。
oops,偶感觉g++比较慢。
 楼主| 发表于 2003-5-2 22:49:56 | 显示全部楼层
我用g++试过,显示同样的错误,当我敲入命令‘gcc -v’时,显示:
Reading specs from
/usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.2/specs
Configured with:
../configure
--prefix=/usr
--libdir=/usr/lib
--with-slibdir=/lib
--mandir=/usr/share/man
--infodir=/usr/share/info
--enable-shared
--enable-threads=posix
--disable-checking
--enable-long-long
--enable-__cxa_atexit
--enable-languages=c,c++,ada,f77,objc,java
--host=i586-mandrake-linux-gnu
--with-system-zlib
Thread model: posix

look at the line:
--enable-languages=c,c++,ada,f77,objc,java
does this mean that it support c,c++,ada,f77,objc, and java?

真是搞不清,闹不明。
发表于 2003-5-3 01:41:20 | 显示全部楼层
你直接用printf不就行了。非要弄个cout。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表