- 论坛徽章:
- 0
|
我初学 照着书写下列程序
#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]] |
|