Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

undefined reference to `std::basic_ostream<...

1 view
Skip to first unread message

Andreas Schmidt

unread,
Dec 19, 2003, 8:17:48 PM12/19/03
to
I have a simple hello world program, but it does not compile:

/tmp/cc0IGuxk.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/cc0IGuxk.o(.text+0x21): In function `main':
: undefined reference to `std::cout'
/tmp/cc0IGuxk.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*)'

... and so on.

I suspect this is just a path problem?

Also, I had to compile it with -I because otherwise it would not find a
lot of h files:
gcc -I/usr/include/g++/i586-suse-linux /tmp/helloworld.cpp

How can I add /usr/include/g++/i586-suse-linux
to the standard paths to look for h files?

The reason for all this mess is that I had replaced some gcc3.3.23 rpms
with gcc3.3.43 rpms, but probably I forgot to update some of them, and so
I got the chaos. Now I copied all 3.3.23 files back, and have these path
issues described above.

Does anyone know how to solve this?

Thanks, Andi

Paul Pluzhnikov

unread,
Dec 20, 2003, 3:04:17 AM12/20/03
to
Andreas Schmidt <schmid...@gmx.de> writes:

> I have a simple hello world program, but it does not compile:

Oh yes it does. What it doesn't do is link (linking and compilation
are separate steps).

> I suspect this is just a path problem?

It isn't. It's a problem of using incorrect compiler front end.
You are obviously compiling C++, you should use g++ for it.

> Also, I had to compile it with -I because otherwise it would not find
> a lot of h files:

Same solution: use 'g++' instead of 'gcc'.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.

Andreas Schmidt

unread,
Dec 20, 2003, 10:02:06 PM12/20/03
to
On 20 Dec 2003 00:04:17 -0800, Paul Pluzhnikov
<ppluzhn...@charter.net> wrote:

> Andreas Schmidt <schmid...@gmx.de> writes:
>
>> I have a simple hello world program, but it does not compile:
>
> Oh yes it does. What it doesn't do is link (linking and compilation
> are separate steps).
>
>> I suspect this is just a path problem?
>
> It isn't. It's a problem of using incorrect compiler front end.
> You are obviously compiling C++, you should use g++ for it.
>
>> Also, I had to compile it with -I because otherwise it would not find
>> a lot of h files:
>
> Same solution: use 'g++' instead of 'gcc'.
>
> Cheers,

Oh, I thought they are equvalent, I'm sorry. Anyway, I tried both, and
g++ always gives me this:

/usr/lib/gcc-lib/i586-suse-linux/3.3/../../../libstdc++.a(eh_throw.o)(.text.__cxa_rethrow+0x48):
In function `__cxa_rethrow':
: undefined reference to `_Unwind_Resume_or_Rethrow'

(see earlier posting from Nov 27)

But I don't care anymore, I am anyway updating my complete OS now... :)

Paul Pluzhnikov

unread,
Dec 21, 2003, 2:35:29 AM12/21/03
to
Andreas Schmidt <schmid...@gmx.de> writes:

> > Same solution: use 'g++' instead of 'gcc'.
>

> Oh, I thought they are equvalent

That is a common misconception.
The differences are quite significant, both at compile and at link time.

0 new messages