This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
explain errors - gcc 3.2.3 with libstdc++-3-libc6.2-2-2.10.0.a
- From: Arvind Mani <marvind434 at yahoo dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Thu, 15 Sep 2005 09:35:08 -0700 (PDT)
- Subject: explain errors - gcc 3.2.3 with libstdc++-3-libc6.2-2-2.10.0.a
I would like to understand why I get link errors
(ostream) when I try to build a simple test program on
RedHat EL 3.0 with gcc 3.2.3 and use an old version of
libstdc++.a.
Here are the steps that I took and the corresponding
output:
1. My test program
cat example.cpp
#include <iostream>
using namespace std;
int main()
{
cout << "hello" << endl;
return 0;
}
2. Build example and link stdc++ statically (I realize
now that I should not use the old version)
gcc -o example example.cpp
/usr/lib/libstdc++-3-libc6.2-2-2.10.0.a
/tmp/cc5liHFR.o(.text+0x14): 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/cc5liHFR.o(.text+0x21): In function `main':
: undefined reference to `std::cout'
/tmp/cc5liHFR.o(.text+0x26): 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/cc5liHFR.o(.text+0x2f): 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/cc5liHFR.o(.text+0x5c): In function
`__static_initialization_and_destruction_0(int, int)':
: undefined reference to
`std::ios_base::Init::Init[in-charge]()'
/tmp/cc5liHFR.o(.text+0x8b): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init
[in-charge]()'
/tmp/cc5liHFR.o(.eh_frame+0x11): undefined reference
to `__gxx_personality_v0'
collect2: ld returned 1 exit status
3. Find the location of the correct version of
libstdc++
gcc -print-file-name=libstdc++.a
/usr/lib/gcc-lib/i386-redhat-linux/3.2.3/libstdc++.a
4. Build again using the correct version
gcc -o example example.cpp
/usr/lib/gcc-lib/i386-redhat-linux/3.2.3/libstdc++.a
Works fine.
My question is why do I get linking errors at all for
symbols such as ostream? I appreciate pointers to
material that will help me understand this process
(compilation and linking) better.
Thanks
______________________________________________________
Yahoo! for Good
Donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/