LinuxSir.cn,穿越时空的Linuxsir!

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

求助一个linux下c++编译的问题?(急啊...)

[复制链接]
发表于 2004-4-2 21:58:19 | 显示全部楼层 |阅读模式
仅仅写了一个hello.cpp:
#include<string>
int main(){
    string hello ;
    return 0 ;
}
运行g++ -o hello.o hello.cpp
出现错误如下:
hello.cpp: In function `int main()':
hello.cpp:4: error: `string' undeclared (first use this function)
hello.cpp:4: error: (Each undeclared identifier is reported only once for each
   function it appears in.)
hello.cpp:4: error: syntax error before `=' token
我打g++ -print-search-dirs显示"Display the directories in the compiler's search path"
出来好多库:
install: /usr/lib/gcc-lib/i386-redhat-linux/3.3.2/
programs: =/usr/lib/gcc-lib/i386-redhat-linux/3.3.2/:/usr/lib/gcc-lib/i386-redhat-linux/3.3.2/:/usr/lib/gcc-lib/i386-redhat-linux/:/usr/lib/gcc/i386-redhat-linux/3.3.2/:/usr/lib/gcc/i386-redhat-linux/:/usr/lib/gcc-lib/i386-redhat-linux/3.3.2/../../../../i386-redhat-linux/bin/i386-redhat-linux/3.3.2/:/usr/lib/gcc-lib/i386-redhat-linux/3.3.2/../../../../i386-redhat-linux/bin/
libraries: =/usr/lib/gcc-lib/i386-redhat-linux/3.3.2/:/usr/lib/gcc/i386-redhat-linux/3.3.2/:/usr/lib/gcc-lib/i386-redhat-linux/3.3.2/../../../../i386-redhat-linux/lib/i386-redhat-linux/3.3.2/:/usr/lib/gcc-lib/i386-redhat-linux/3.3.2/../../../../i386-redhat-linux/lib/:/usr/lib/gcc-lib/i386-redhat-linux/3.3.2/../../../i386-redhat-linux/3.3.2/:/usr/lib/gcc-lib/i386-redhat-linux/3.3.2/../../../:/lib/i386-redhat-linux/3.3.2/:/lib/:/usr/lib/i386-redhat-linux/3.3.2/:/usr/lib/
也就是说找不到c++的库...
我的系统是fedora
请高手指教,多谢!!!

    :help :help :help
发表于 2004-4-2 23:48:22 | 显示全部楼层
you need:
using namespace std;
发表于 2004-4-2 23:58:12 | 显示全部楼层
you need:
using namespace std;
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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