使用gcc时出现问题

软件和网站开发以及相关技术探讨
回复
ryanli
帖子: 54
注册时间: 2007-08-25 17:48
联系:

使用gcc时出现问题

#1

帖子 ryanli » 2007-10-16 13:31

重装了系统,发现gcc编译是总是有错误:

代码: 全选

/tmp/ccgS00Qz.o: In function `__static_initialization_and_destruction_0(int, int)':
helloworld.cc:(.text+0x23): undefined reference to `std::ios_base::Init::Init()'
/tmp/ccgS00Qz.o: In function `__tcf_0':
helloworld.cc:(.text+0x6c): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccgS00Qz.o: In function `main':
helloworld.cc:(.text+0x8e): undefined reference to `std::cout'
helloworld.cc:(.text+0x93): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccgS00Qz.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
就连最简单的helloworld.cc也是:

代码: 全选

#include <iostream>

using namespace std;

int main()
{
	cout << "Hello World!";
}
头像
BigSnake.NET
帖子: 12522
注册时间: 2006-07-02 11:16
来自: 廣州
联系:

#2

帖子 BigSnake.NET » 2007-10-16 13:43

后缀名cpp
用g++ 编译
^_^ ~~~
要理解递归,首先要理解递归。

地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
ryanli
帖子: 54
注册时间: 2007-08-25 17:48
联系:

#3

帖子 ryanli » 2007-10-16 13:53

还是不行
头像
madoldman
帖子: 599
注册时间: 2006-02-27 20:19
来自: works system
联系:

#4

帖子 madoldman » 2007-10-16 13:55

使用g++编译,或者用gcc加-lstdc++
扩展名用cc没用问题
东西路,南北走
十字路口人咬狗
拿起狗来打砖头
砖头咬了狗一口
图片
ryanli
帖子: 54
注册时间: 2007-08-25 17:48
联系:

#5

帖子 ryanli » 2007-10-17 13:19

依然没反应,但是没报错了
头像
madoldman
帖子: 599
注册时间: 2006-02-27 20:19
来自: works system
联系:

#6

帖子 madoldman » 2007-10-17 16:51

你要什么反应?
东西路,南北走
十字路口人咬狗
拿起狗来打砖头
砖头咬了狗一口
图片
ryanli
帖子: 54
注册时间: 2007-08-25 17:48
联系:

#7

帖子 ryanli » 2007-10-21 8:50

也要输出"Hello World!"啊
回复