From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26481 invoked by alias); 7 Mar 2003 05:56:27 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 26474 invoked from network); 7 Mar 2003 05:56:26 -0000 Received: from unknown (HELO lifesupport.shutdown.com) (66.93.79.177) by 172.16.49.205 with SMTP; 7 Mar 2003 05:56:26 -0000 Received: (from llewelly@localhost) by lifesupport.shutdown.com (8.11.2/8.11.2) id h275rR620409; Thu, 6 Mar 2003 21:53:27 -0800 (PST) To: Cc: "Klein, Bernhard" , "GCC Help" Subject: Re: gcc 3.2.2 & STL library Reply-To: gcc-help@gcc.gnu.org References: From: LLeweLLyn Reese Date: Fri, 07 Mar 2003 05:56:00 -0000 In-Reply-To: Message-ID: User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-03/txt/msg00091.txt.bz2 "Michael H. Cox" 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 /lib . By default is /usr/local. You can check the value of 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]