Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 03-23-2008, 05:50 AM   #1
Registered: Oct 2007
Posts: 160

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


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 ( (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/ 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/ version `GLIBCXX_3.4.9' not found (required by ./a.out) => /usr/lib/ (0x00829000) => /lib/tls/ (0x00517000) => /lib/ (0x007e1000) => /lib/tls/ (0x003eb000)
/lib/ (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 => /usr/lib/ (0x00829000) => /lib/tls/ (0x00517000) => /lib/ (0x007e1000) => /lib/tls/ (0x003eb000)
/lib/ (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 07:01 AM.
Old 03-23-2008, 08:27 AM   #2
LQ Addict
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Jessie 8.4
Posts: 5,867

Rep: Reputation: 345Reputation: 345Reputation: 345Reputation: 345
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 08:34 AM.
Old 03-24-2008, 01:18 AM   #3
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 => /usr/local/lib/ (0x00400000) => /usr/local/lib/ (0x007be000) => /lib/tls/ (0x00517000) => /lib/tls/ (0x00111000)
/lib/ (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

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 01:20 AM.


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/ version `GLIBCXX_3.4.9' not found (required by ./example1) babu198649 Linux - Newbie 24 12-02-2010 04: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 06:33 AM version `GCC_4.2.0' not found (required by /usr/bin/../lib/libstdc++.s hferretluv Linux - Software 4 12-18-2006 12:31 PM
Compromised? Files "/usr/lib.hwm", "/usr/lib.pwd", "/usr/lib.pwi" Klaus Pforte Linux - Security 4 09-28-2004 11:33 PM
/usr/lib/ version 'GLIBCPP_3.2.2' not found vidi Linux - Software 1 06-10-2004 09:26 AM

All times are GMT -5. The time now is 02:33 AM.

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