关于GCC的问题

xueshupan 2005-05-27 02:23:09
对于一个简单的程序比如:
#include<iostream>
int main(int argc,char* argv[]){
std::cout<<8;
return 0;
}

我用GCC可以编译但连接的时候出现以下错误:
: undefined reference to `std::cout'
why.o(.text+0x1b): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(int)'
why.o(.text+0x48): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init[in-charge]()'
why.o(.text+0x77): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init [in-charge]()'
why.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
但是用g++就没有问题了
怎么回事?怎么解决?
谢谢!

...全文
116 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
flyingsnow1999 2005-05-28
  • 打赏
  • 举报
回复
g++
property1 2005-05-28
  • 打赏
  • 举报
回复
g++
NC 2005-05-27
  • 打赏
  • 举报
回复
gcc是C编译器
g++才是编译c++的
积木 2005-05-27
  • 打赏
  • 举报
回复
第一 加上using namespace std;
第二 gcc本来就不是用来编译C++文件的,一定要用g++编译 gcc是用来编译c文件的
还有,GCC的全称应该是GNU Compiler Collection 和里面的gcc是两个东西……

23,110

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧