|
|

楼主 |
发表于 2007-6-12 10:07:23
|
显示全部楼层
可能我使用GCC方法出错了吧,各位能给我个简单的提示吗?比如下面最简单的C++代码保存为example.cpp,然后如何编译输出?
#include <iostream>
int mai()
{
using namespace std;
cout<<"Hello!"<<endl;
return 0;
}
在F7是编译的结果如下,提示我没有定义,不知道怎么办。。。。。。。。。。。
[yabu25@yabu Desktop]$ gcc -o 1 1.cpp
/usr/lib/gcc/i386-redhat-linux/4.1.2/../../../crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
/tmp/ccdxhDmk.o: In function `__static_initialization_and_destruction_0(int, int)':
1.cpp .text+0x23): undefined reference to `std::ios_base::Init::Init()'
/tmp/ccdxhDmk.o: In function `__tcf_0':
1.cpp .text+0x6c): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccdxhDmk.o: In function `mai()':
1.cpp .text+0x83): undefined reference to `std::cout'
1.cpp .text+0x88): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std: perator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
1.cpp .text+0x90): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
1.cpp .text+0x98): undefined reference to `std::basic_ostream<char, std::char_traits<char> >: perator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
/tmp/ccdxhDmk.o .eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld 返回 1
[yabu25@yabu Desktop]$ |
|