LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 03-23-2008, 06:50 AM   #1
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Rep: Reputation: 30
"/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found" solved but stil confused


hi

i have red hat linux installed in my system.

[babu@localhost h]$ uname -a
Linux localhost.localdomain 2.6.9-22.ELsmp #1 SMP Mon Sep 19 18:32:14 EDT 2005 i686 i686 i386 GNU/Linux

[babu@localhost h]$ cat /proc/version
Linux version 2.6.9-22.ELsmp (bhcompile@porky.build.redhat.com) (gcc version 3.4.4 20050721 (Red Hat 3.4.4-2)) #1 SMP Mon Sep 19 18:32:14 EDT 2005



the default gcc compiler version is gcc version 3.4.4 which had present in my system.


i have upgraded the gcc to version 4.2.2.

now when i compiled the program (which uses external library) ,there was no problem. but when i run the program i got the following error.

[babu@localhost h]$ ./a.out
./a.out: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by ./a.out)


when i used ldd command to view the shared dependencies i got the following

[babu@localhost h]$ ldd ./a.out
./a.out: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by ./a.out)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00829000)
libm.so.6 => /lib/tls/libm.so.6 (0x00517000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x007e1000)
libc.so.6 => /lib/tls/libc.so.6 (0x003eb000)
/lib/ld-linux.so.2 (0x003d2000)



here i have noticed that the gcc(version 4.2.2)libraries reside in /usr/local/lib

but note that in the above command the program is linked to libraries which is residing in the /usr/lib path (which is the old gcc version library path)

so i explicitly gave the library path in the command like this which points to gcc-4.2.2 version libraries.

[babu@localhost h]$ g++ -Wall simple_xy_wr.cpp /usr/local/lib/libnetcdf_c++.a /usr/local/lib/libnetcdf.a /usr/local/lib/libstdc++.a


and now its working fine and when the shared dependencies are checked i got this

[babu@localhost h]$ ldd a.out
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00829000)
libm.so.6 => /lib/tls/libm.so.6 (0x00517000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x007e1000)
libc.so.6 => /lib/tls/libc.so.6 (0x003eb000)
/lib/ld-linux.so.2 (0x003d2000)



ie. there is no change in the dependency path but after specifying the library path while compiling its working very

now i wnt to uninstall the old gcc(which is given by distro ,how to uninstall) or
is there any other solution for this problem(such as always the gcc command links to libraries in the path /usr/local/lib/ rather than pointing to old gcc version libraries which is present in /usr/lib/ path)

Last edited by babu198649; 03-23-2008 at 08:01 AM.
 
Old 03-23-2008, 09:27 AM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,795

Rep: Reputation: 312Reputation: 312Reputation: 312Reputation: 312
When you link programs with libraries, the linker doesn't use the full path to the library; only the library name. The standard libraries to use are /lib and /usr/lib. Any others must be given in the compile command.

At run-time, the system will search only /lib and /usr/lib for the libraries. If they are not found, you get error messages.

To fix that, you need to add "-W1,rpath" option with the path to additional libraries, like so:
g++ -Wall simple_xy_wr.cpp /usr/local/lib/libnetcdf_c++.a /usr/local/lib/libnetcdf.a -W1,rpath,/usr/local/lib.

Now the system should search the standard /lib and /usr/lib, plus /usr/local/lib, at run-time.

Reference: Advanced Linux Programming, ch. 2, section 3.4, Library Dependencies

Last edited by bigrigdriver; 03-23-2008 at 09:34 AM.
 
Old 03-24-2008, 02:18 AM   #3
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Original Poster
Rep: Reputation: 30
thanks for reply

the problem with my compilation is not with the external libraries.
i had downloaded the netcdf(c and c++ libraries) package and compiled with make which had been generated by configure(configure file was given in the package)

there are examples within the main directory of the package and those examples also compile with make . now when i had checked for the dependencies(for the example programs which had been compiled with the make file and it resides within the main directory of the package) it says


[babu@localhost CXX]$ ldd simple_xy_wr
libstdc++.so.6 => /usr/local/lib/libstdc++.so.6 (0x00400000)
libgcc_s.so.1 => /usr/local/lib/libgcc_s.so.1 (0x007be000)
libm.so.6 => /lib/tls/libm.so.6 (0x00517000)
libc.so.6 => /lib/tls/libc.so.6 (0x00111000)
/lib/ld-linux.so.2 (0x003d2000)


now i copied the same example program outside the package directory and tried to execute
and i get the problems mentioned in the above post.

the examples compiled by the package depends on libraries in the path
/usr/local/lib/

where as if i compile the same example and it depends on libraries in the path
/usr/lib/ which can be seen in the above post.


could u help me to uninstall the gcc compiler.the make file with which i had installed the gcc does not support uninstallation.

Last edited by babu198649; 03-24-2008 at 02:20 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by ./example1) babu198649 Linux - Newbie 24 12-02-2010 05:09 AM
Can't locate object method "splitpath" via package "PACK001" at /usr/lib/perl5/5.8.8/ sajigeorge Linux - Software 1 01-11-2009 07:33 AM
libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/bin/../lib/libstdc++.s hferretluv Linux - Software 4 12-18-2006 01:31 PM
Compromised? Files "/usr/lib.hwm", "/usr/lib.pwd", "/usr/lib.pwi" Klaus Pforte Linux - Security 4 09-29-2004 12:33 AM
/usr/lib/libstdc++.so.5: version 'GLIBCPP_3.2.2' not found vidi Linux - Software 1 06-10-2004 10:26 AM


All times are GMT -5. The time now is 03:22 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration