public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* string
@ 2005-03-21 14:50 Mohammad shojatalab
  2005-03-21 16:13 ` string Eljay Love-Jensen
  0 siblings, 1 reply; 2+ messages in thread
From: Mohammad shojatalab @ 2005-03-21 14:50 UTC (permalink / raw)
  To: gcc-help

Hi ,
I have a simple C++ program: (test.cpp)

#include <iostream>
#include <string>
using namespace std;

int main ()
{
     string file="Hello World!";
     return 0;

}

but when I try to compile it this is what I get:
/usr/bin/gcc -o test test.cpp
/tmp/cc3PgfJI.o(.text+0x1c): In function `main':
: undefined reference to `std::allocator<char>::allocator[in-charge]()'
/tmp/cc3PgfJI.o(.text+0x31): In function `main':
: undefined reference to `std::basic_string<char, 
std::char_traits<char>, std::allocator<char> 
 >::basic_string[in-charge](char const*, std::allocator<char> const&)'
/tmp/cc3PgfJI.o(.text+0x48): In function `main':
: undefined reference to `std::allocator<char>::~allocator [in-charge]()'
/tmp/cc3PgfJI.o(.text+0x65): In function `main':
: undefined reference to `std::allocator<char>::~allocator [in-charge]()'
/tmp/cc3PgfJI.o(.text+0x74): In function `main':
: undefined reference to `std::basic_string<char, 
std::char_traits<char>, std::allocator<char> >::~basic_string [in-charge]()'
/tmp/cc3PgfJI.o(.text+0xa4): In function 
`__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init[in-charge]()'
/tmp/cc3PgfJI.o(.text+0xd3): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init [in-charge]()'
/tmp/cc3PgfJI.o(.eh_frame+0x12): undefined reference to 
`__gxx_personality_v0'
collect2: ld returned 1 exit status

these are what I have:
cpp-3.2.2-5
libstdc++-devel-3.2.2-5
compat-libstdc++-7.3-2.96.118
compat-gcc-c++-7.3-2.96.118
compat-libstdc++-devel-7.3-2.96.118
gcc-c++-3.2.2-5
libstdc++-3.2.2-5
gcc-g77-3.2.2-5
gcc-gnat-3.2.2-5
gcc-3.2.2-5



Whats wrong?

any anwer/suggestion is highly appreciated.

Mohammad


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: string
  2005-03-21 14:50 string Mohammad shojatalab
@ 2005-03-21 16:13 ` Eljay Love-Jensen
  0 siblings, 0 replies; 2+ messages in thread
From: Eljay Love-Jensen @ 2005-03-21 16:13 UTC (permalink / raw)
  To: Mohammad shojatalab, gcc-help

Hi Mohammad,

>Whats wrong?

You should use the GCC C++ compiler/linker toolchain instead of the GCC C compiler/linker toolchain.

/usr/bin/g++ -o test test.cpp

HTH,
--Eljay

PS:  when you run it, you'll need to type...
./test
...so you don't get /bin/test by accident.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-03-21 14:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-21 14:50 string Mohammad shojatalab
2005-03-21 16:13 ` string Eljay Love-Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).