免费注册 查看新帖 |

Chinaunix

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

菜鸟请教问题 iostream报错? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-11-12 03:10 |只看该作者 |倒序浏览
我初学 照着书写下列程序
#include <iostream>
int main()
{
        std::cout << "Enter two numbers:" <<std::endl;
        int v1,v2;
        std::cin >> v1 >>v2;
        std::cout << "The sum of " << v1 << " and " << v2 << " is " << v1 + v2 << std::endl;
        return 0;
}


然后编译
cc program_1.2.1.cc   
结果系统出了一堆东西。。。

如下
/tmp/cclI5fW2.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/cclI5fW2.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> >::operator[](unsigned int) const'
/tmp/cclI5fW2.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> >::operator[](unsigned int) const'
/tmp/cclI5fW2.o(.text+0xc8): 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> >::operator[](unsigned int) const'
/tmp/cclI5fW2.o(.text+0x11c): In function `main':
: 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> >&)'
/tmp/cclI5fW2.o(.text+0x129): In function `main':
: undefined reference to `std::cout'
/tmp/cclI5fW2.o(.text+0x12e): 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/cclI5fW2.o(.text+0x137): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
/tmp/cclI5fW2.o(.text+0x14d): In function `main':
: undefined reference to `std::cin'
/tmp/cclI5fW2.o(.text+0x152): In function `main':
: undefined reference to `std::basic_istream<char, std::char_traits<char> >::operator>>(int&)'
/tmp/cclI5fW2.o(.text+0x15b): In function `main':
: undefined reference to `std::basic_istream<char, std::char_traits<char> >::operator>>(int&)'
/tmp/cclI5fW2.o(.text+0x166): In function `main':
: 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> >&)'
/tmp/cclI5fW2.o(.text+0x199): In function `main':
: undefined reference to `std::cout'
/tmp/cclI5fW2.o(.text+0x19e): 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/cclI5fW2.o(.text+0x1a7): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(int)'
/tmp/cclI5fW2.o(.text+0x1b0): 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/cclI5fW2.o(.text+0x1b9): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(int)'
/tmp/cclI5fW2.o(.text+0x1c2): 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/cclI5fW2.o(.text+0x1cb): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(int)'
/tmp/cclI5fW2.o(.text+0x1d4): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
/tmp/cclI5fW2.o(.text+0x200): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init()'
/tmp/cclI5fW2.o(.text+0x22f): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init()'
/tmp/cclI5fW2.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status


请教大侠们  是怎么回事?程序和书上的一样的啊。。。无奈中。。。
谢谢!

[[i] 本帖最后由 ACperl 于 2007-11-12 03:11 编辑 [/i]]

论坛徽章:
0
2 [报告]
发表于 2007-11-12 03:29 |只看该作者
原帖由 ACperl 于 2007-11-11 11:10 发表
我初学 照着书写下列程序
#include
int main()
{
        std::cout >v2;
        std::cout  


cc program_1.2.1.cc 改成 g++ program_1.2.1.cc

论坛徽章:
0
3 [报告]
发表于 2007-11-12 04:13 |只看该作者
:wink:   非常感谢。。。。。我真是菜到家了  哈哈哈

谢谢!!!

论坛徽章:
0
4 [报告]
发表于 2007-11-12 11:52 |只看该作者
using namespace std;
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP