免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2565 | 回复: 5
打印 上一主题 下一主题

如此简单的程序,竟然有 这么多的错误? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-06-30 16:55 |只看该作者 |倒序浏览
在 linux下编译tt.C,
tt.C的内容如下:
#include <iostream>;
using  namespace std;
int main(){
cout << "line:"<<__LINE__<< "\n";
cout << "file:"<<__FILE__<< "\n";
cout << "date:"<<__DATE__<< "\n";
#ifndef __cplusplus
cout << "time:"<<__TIME__<< "\n";
#endif
return 0;
}

编译的 命令是cc text.C
结果如下:
/tmp/ccreYPMX.o(.text+0xd): In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>;, std::allocator<char>; >; const&':
: undefined reference to `std::basic_string<char, std::char_traits<char>;, std::allocator<char>; >;::size() const'
/tmp/ccreYPMX.o(.text+0x60): In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>;, std::allocator<char>; >; const&':
: undefined reference to `std::basic_string<char, std::char_traits<char>;, std::allocator<char>; >;:perator[](unsigned int) const'
/tmp/ccreYPMX.o(.text+0x9d): In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>;, std::allocator<char>; >; const&':
: undefined reference to `std::basic_string<char, std::char_traits<char>;, std::allocator<char>; >;:perator[](unsigned int) const'
/tmp/ccreYPMX.o(.text+0xc: In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>;, std::allocator<char>; >; const&':
: undefined reference to `std::basic_string<char, std::char_traits<char>;, std::allocator<char>; >;:perator[](unsigned int) const'
/tmp/ccreYPMX.o(.text+0x12e): In function `main':
: undefined reference to `std::cout'
/tmp/ccreYPMX.o(.text+0x133): 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/ccreYPMX.o(.text+0x13c): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char>; >;:perator<<(int)'
/tmp/ccreYPMX.o(.text+0x145): 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/ccreYPMX.o(.text+0x165): In function `main':
: undefined reference to `std::cout'
/tmp/ccreYPMX.o(.text+0x16a): 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/ccreYPMX.o(.text+0x173): 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/ccreYPMX.o(.text+0x17c): 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/ccreYPMX.o(.text+0x19c): In function `main':
: undefined reference to `std::cout'
/tmp/ccreYPMX.o(.text+0x1a1): 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/ccreYPMX.o(.text+0x1aa): In function `main':
: 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/ccreYPMX.o(.text+0x1b3): In function `main':
: 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/ccreYPMX.o(.text+0x1e0): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init()'
/tmp/ccreYPMX.o(.text+0x20f): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccreYPMX.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
说我什么这么多的函数没用,不加using,又说我的cout未定义。
郁闷

论坛徽章:
0
2 [报告]
发表于 2005-06-30 17:24 |只看该作者

如此简单的程序,竟然有 这么多的错误?

c++ test.c

论坛徽章:
0
3 [报告]
发表于 2005-06-30 18:25 |只看该作者

如此简单的程序,竟然有 这么多的错误?

$g++

论坛徽章:
0
4 [报告]
发表于 2005-07-01 09:16 |只看该作者

如此简单的程序,竟然有 这么多的错误?

mv test.C test.cpp
g++ test.cpp

论坛徽章:
0
5 [报告]
发表于 2006-04-19 11:57 |只看该作者
呵呵,谢了

论坛徽章:
0
6 [报告]
发表于 2006-04-19 12:53 |只看该作者
晕c++用cc编译
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP