This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc 3.2.2 & STL library


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

> > -----Original Message-----
> > From: Klein, Bernhard [mailto:Bernhard dot Klein at logicacmg dot com]
> > Sent: Monday, February 24, 2003 6:30 AM
> > To: 'gcc-help at gcc dot gnu dot org'; 'gcc-help-faq at gcc dot gnu dot 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]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]