红联Linux门户
Linux帮助

g++和gcc的区别

发布时间:2008-05-21 16:26:01来源:红联作者:ytu_cyc
程序:test.cpp
内容:
#include
using namespace std;
int main()
{
cout<<"Hello,Ubuntu..."< return 0;
}
用g++可以编译且执行
用gcc编译通不过。
这是为什么??谢谢!!!

出错信息:
ubuntu@ubuntu:~/C$ gcc -o cpp test.cpp
/tmp/ccIhWs0N.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x23): undefined reference to `std::ios_base::Init::Init()'
/tmp/ccIhWs0N.o: In function `__tcf_0':
test.cpp:(.text+0x6c): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccIhWs0N.o: In function `main':
test.cpp:(.text+0x8e): undefined reference to `std::cout'
test.cpp:(.text+0x93): undefined reference to `std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)'
test.cpp:(.text+0x9b): undefined reference to `std::basic_ostream >& std::endl >(std::basic_ostream >&)'
test.cpp:(.text+0xa3): undefined reference to `std::basic_ostream >::operator<<(std::basic_ostream >& (*)(std::basic_ostream >&))'
/tmp/ccIhWs0N.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
文章评论

共有 1 条评论

  1. 黄富强 于 2008-05-21 17:18:32发表:

    研究完这个,你就明白了,gcc是交叉编译器,或者叫跨语言编译器,你想它会如何实现?
    gcc和g++的区别
    http://hi.baidu.com/guoyanjoy2/blog/item/cfd14bcb978478f952664f14.html

    [ 本帖最后由 黄富强 于 2008-5-21 17:27 编辑 ]