public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc 3.2.2 & STL library
@ 2003-02-24 13:29 Klein, Bernhard
  2003-02-25  6:06 ` Michael H. Cox
  0 siblings, 1 reply; 3+ messages in thread
From: Klein, Bernhard @ 2003-02-24 13:29 UTC (permalink / raw)
  To: 'gcc-help@gcc.gnu.org', 'gcc-help-faq@gcc.gnu.org'


Hi All,

I'm a newbie in gcc under Solaris 2.9 and try to work with the actual gcc
release 3.2.2 and STL. 

I made a very simple c++ program including some STL functions ( like string,
iostream, etc). 
Compiling like this g++ -o cppstl cppstl.cpp
works fine without compiler or linker errors, but after starting the program
I got this error:
ld.so.1: cppstl: fatal: relocation error: file cppstl: symbol _ZSt4cout:
referenced symbol not found
Killed

mhm, It seems that my binary can'T find a library or something else ( but I
don't know which library or what ever needed ).

After compiling with:    g++ -static -o cppstl cppstl.cpp
my little program works fine.

I hope that somebody can help me.

Bernd Klein 
---------------------------------------------------------- 
Logica GmbH 
Financial Services, GB 21 
Faulenstraße 31-35 
28195 Bremen 
Phone : +49 421 30 96-121 
Fax : +49 421 30 96-118 
Email : kleinbe@logica.com 
---------------------------------------------------------- 

This e-mail and any attachment is for authorised use by the intended recipient(s) only.  It may contain proprietary material, confidential information and/or be subject to legal privilege.  It should not be copied, disclosed to, retained or used by, any other party.  If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.  Thank you.

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

* RE: gcc 3.2.2 & STL library
  2003-02-24 13:29 gcc 3.2.2 & STL library Klein, Bernhard
@ 2003-02-25  6:06 ` Michael H. Cox
  2003-03-07  5:56   ` LLeweLLyn Reese
  0 siblings, 1 reply; 3+ messages in thread
From: Michael H. Cox @ 2003-02-25  6:06 UTC (permalink / raw)
  To: Klein, Bernhard; +Cc: GCC Help



> -----Original Message-----
> From: Klein, Bernhard [mailto:Bernhard.Klein@logicacmg.com]
> Sent: Monday, February 24, 2003 6:30 AM
> To: 'gcc-help@gcc.gnu.org'; 'gcc-help-faq@gcc.gnu.org'
> Subject: gcc 3.2.2 & STL library
>
>
>
> Hi All,
>
> I'm a newbie in gcc under Solaris 2.9 and try to work with the actual gcc
> release 3.2.2 and STL.
>
> I made a very simple c++ program including some STL functions (
> like string,
> iostream, etc).
> Compiling like this g++ -o cppstl cppstl.cpp
> works fine without compiler or linker errors, but after starting
> the program
> I got this error:
> ld.so.1: cppstl: fatal: relocation error: file cppstl: symbol _ZSt4cout:
> referenced symbol not found
> Killed
>
> mhm, It seems that my binary can'T find a library or something
> else ( but I
> don't know which library or what ever needed ).

Try adding -lstdc++ to your compile line and see what happens.

>
> After compiling with:    g++ -static -o cppstl cppstl.cpp
> my little program works fine.

Not sure why this would fix your problem since the compiler still doesn't
know that it need to link to stdc++, either statically or dynamically.  So
the above suggestion may not help.

>
> I hope that somebody can help me.
>
> Bernd Klein
> ----------------------------------------------------------
> Logica GmbH
> Financial Services, GB 21
> Faulenstraße 31-35
> 28195 Bremen
> Phone : +49 421 30 96-121
> Fax : +49 421 30 96-118
> Email : kleinbe@logica.com
> ----------------------------------------------------------
>
> This e-mail and any attachment is for authorised use by the
> intended recipient(s) only.  It may contain proprietary material,
> confidential information and/or be subject to legal privilege.
> It should not be copied, disclosed to, retained or used by, any
> other party.  If you are not an intended recipient then please
> promptly delete this e-mail and any attachment and all copies and
> inform the sender.  Thank you.
>

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

* Re: gcc 3.2.2 & STL library
  2003-02-25  6:06 ` Michael H. Cox
@ 2003-03-07  5:56   ` LLeweLLyn Reese
  0 siblings, 0 replies; 3+ messages in thread
From: LLeweLLyn Reese @ 2003-03-07  5:56 UTC (permalink / raw)
  To: mhcox; +Cc: Klein, Bernhard, GCC Help

"Michael H. Cox" <mhcox@bluezoosoftware.com> writes:

> > -----Original Message-----
> > From: Klein, Bernhard [mailto:Bernhard.Klein@logicacmg.com]
> > Sent: Monday, February 24, 2003 6:30 AM
> > To: 'gcc-help@gcc.gnu.org'; 'gcc-help-faq@gcc.gnu.org'
> > Subject: gcc 3.2.2 & STL library
> >
> >
> >
> > Hi All,
> >
> > I'm a newbie in gcc under Solaris 2.9 and try to work with the actual gcc
> > release 3.2.2 and STL.
> >
> > I made a very simple c++ program including some STL functions (
> > like string,
> > iostream, etc).
> > Compiling like this g++ -o cppstl cppstl.cpp
> > works fine without compiler or linker errors, but after starting
> > the program
> > I got this error:
> > ld.so.1: cppstl: fatal: relocation error: file cppstl: symbol _ZSt4cout:
> > referenced symbol not found
> > Killed

Probably you need to add the directory containing libstdc++.so.5 to
    your LD_LIBRARY_PATH . By default that dir is <prefix>/lib . By
    default <prefix> is /usr/local. You can check the value of
    <prefix> by running gcc -v, and looking for a bit of the form
    '--prefix=some_dir_name' If you can't find it, prefix is
    /usr/local, the default.

$export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

(for sh)

>export LD_LIBRARY_PATH = /usr/local/lib:$LD_LIBRARY_PATH

(for csh)

should fix your problem, if /usr/local is your prefix.

Please read 'man ld.so.1' for more info about LD_LIBRARY_PATH .


> >
> > mhm, It seems that my binary can'T find a library or something
> > else ( but I
> > don't know which library or what ever needed ).
> 
> Try adding -lstdc++ to your compile line and see what happens.

No, using g++ (instead of gcc) does that automagicly.

> 
> >
> > After compiling with:    g++ -static -o cppstl cppstl.cpp
> > my little program works fine.
> 
> Not sure why this would fix your problem since the compiler still doesn't
> know that it need to link to stdc++, either statically or dynamically.  So
> the above suggestion may not help.

His problem is that a shared library is not in
    any of the directories searched by ld.so.1, his dynamic
    linker. Using -static prevents use of shared libraries, making it
    no longer necessary for the shared lib to be found. So -static
    solves his problem.

[snip]

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

end of thread, other threads:[~2003-03-07  5:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-24 13:29 gcc 3.2.2 & STL library Klein, Bernhard
2003-02-25  6:06 ` Michael H. Cox
2003-03-07  5:56   ` LLeweLLyn Reese

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).