LinuxSir.cn,穿越时空的Linuxsir!

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

编译出错:抄错了?

[复制链接]
发表于 2003-9-4 22:36:10 | 显示全部楼层 |阅读模式
//////////test.cpp

#include <iostream>

using namespace std;


int main()
{
        cout << "Hello World!\n";
}                                 

slackware@linux:~/test$gcc test.cpp -o test
/tmp/cc7wDNwy.o(.text+0x19): In function `main':
: undefined reference to `std::cout'
/tmp/cc7wDNwy.o(.text+0x1e): In function `main':
: 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*)'
/tmp/cc7wDNwy.o(.text+0x4a): In function `__static_initialization_and_destructio
n_0(int, int)':
: undefined reference to `std::ios_base::Init::Init[in-charge]()'
/tmp/cc7wDNwy.o(.text+0x79): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init [in-charge]()'
/tmp/cc7wDNwy.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status


这个都不知道是那里错了.
发表于 2003-9-4 22:53:10 | 显示全部楼层
gcc test.cpp -o test
应该用:
g++ test.cpp -o test
 楼主| 发表于 2003-9-5 07:09:53 | 显示全部楼层

找到这么一段,谢谢!

gcc is a compiler for C, supporting (with the -traditional flag) Kernighan and Ritchie`s dialect, (with the -ansi flag) the ANSI dialect and (by default) itsown somewhat enhanced dialect.
g++ and c++ are (identical as far as I can see) compilers for C++.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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