LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   "/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found" worked but stil confused (http://www.linuxquestions.org/questions/linux-newbie-8/usr-lib-libstdc-so-6-version-%60glibcxx_3-4-9-not-found-worked-but-stil-confused-629999/)

babu198649 03-23-2008 05:50 AM

"/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:confused: very:confused:

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)

bigrigdriver 03-23-2008 08:27 AM

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

babu198649 03-24-2008 01:18 AM

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.


All times are GMT -5. The time now is 05:55 AM.