[svlug] interesting and exotic linking error in .o files of cpp program

Jonathan Su axolotlpacman at sbcglobal.net
Tue Nov 18 13:23:04 PST 2003


many people say if you are good at C, you can learn
any language, as I was running a already tested c code
and compiling it, an interesting and exotic linking
error occurred, I am not certain whether this has to
do with my red hat distribution, after analyzing the
situation with abstract thoughts, I think it might be
some compatibility issues with cout and cin with my
particular library and compiler, it is just a guess.
If anybody have any constructive criticism or
comments, please let me know, thanks.

*************************actual
program****************
#include <iostream>
using namespace std;

int main()
{
   int i;
   double x;

   cout << "\nEnter a double; ";
   cin >> x;
   cout << "Enter a positive integer: ";
   cin >> i;
   while (i< 1) {
           cerr << "errpr i = " << i << endl;
           cout << "Enter a positive integer; ";
           cin >> i;
   };
   cout << "i *x = " << i*x <<endl;
}
**************************output**********************
[pacman at localhost C]$ gcc io.cpp
/tmp/cc2KYP8A.o: In function `main':
/tmp/cc2KYP8A.o(.text+0x19): undefined reference to
`std::cout'
/tmp/cc2KYP8A.o(.text+0x1e): 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/cc2KYP8A.o(.text+0x2d): undefined reference to
`std::cin'
/tmp/cc2KYP8A.o(.text+0x32): undefined reference to
`std::basic_istream<char, std::char_traints<char>
>::operator>>(double&)'
/tmp/cc2KYP8A.o(.text+0x42): undefined reference to
`std::cout'
/tmp/cc2KYP8A.o(.text+0x47): 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/cc2KYP8A.o(.text+0x56): undefined reference to
`std::cin'
/tmp/cc2KYP8A.o(.text+0x5b): undefined reference to
`std::basic_istream<char, std::char_traints<char>
>::operator>>(int&)'
/tmp/cc2KYP8A.o(.text+0x6e): 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/cc2KYP8A.o(.text+0x81): undefined reference to
`std::cerr'
/tmp/cc2KYP8A.o(.text+0x86): 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/cc2KYP8A.o(.text+0x8f): undefined reference to
`std::basic_ostream<char, std::char_traits<char>
>::operator<<(int)'
/tmp/cc2KYP8A.o(.text+0x98): 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/cc2KYP8A.o(.text+0xa8): undefined reference to
`std::cout'
/tmp/cc2KYP8A.o(.text+0xad): 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/cc2KYP8A.o(.text+0xbc): undefined reference to
`std::cin'
/tmp/cc2KYP8A.o(.text+0xc1): undefined reference to
`std::basic_istream<char, std::char_traints<char>
>::operator>>(int&)'
/tmp/cc2KYP8A.o(.text+0xce): 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/cc2KYP8A.o(.text+0xeb): undefined reference to
`std::cout'
/tmp/cc2KYP8A.o(.text+0xf0): 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/cc2KYP8A.o(.text+0xf9): undefined reference to
`std::basic_ostream<char, std::char_traits<char>
>::operator<<(double)'
/tmp/cc2KYP8A.o(.text+0x102): 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/cc2KYP8A.o: In function
`__static_initialization_and_destruction_0(int, int)':
/tmp/cc2KYP8A.o(.text+0x12e): undefined reference to
`std::ios_base::Init::Init[in-charge]()'
/tmp/cc2KYP8A.o: In function `__tcf_0':
/tmp/cc2KYP8A.o(.text+0x15d): undefined reference to
`std::ios_base::Init::~Init [in-charge]()'
/tmp/cc2KYP8A.o(.eh_frame+0x11): undefined reference
to `__gxx_personality_v0'
collect2: ld returned 1 exit status





More information about the svlug mailing list