Advertisement

Problems with G++: Missing Libraries

Started by July 11, 2003 01:02 PM
2 comments, last by Extrarius 21 years, 4 months ago
I''m trying to compile some stuff with g++ using a library but I continue to get linker errors:
$ g++ -I/somepath -lSomeLib -L/somepath file1.cpp file2.cpp
...
/usr/bin/ld: warning: libstdc++-libc6.1-2.so.3, needed by /somepath/libSomeLib.so, not found (try using --r
path)
$ ./a.out
./a.out: error in loading shared libraries: libSomeLib.so: cannot open shared object file: No such file or director
. I''ve recompile the library which I assumed would make it use the version of libsedc++ on the computer but it didn''t remove the error. I couldn''t find the specified library anywhere (I figured it might be for download from the gcc site or something but didn''t see that version of it anywhere). I''m forced to use RedHat 6.2 and gcc 2.95.2 for this project if that matters (and yes the library is supposed to be able to work with those). Any ideas on how I could fix this?
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
About the first part: that's the standard C++ library GCC has been told to use, it's probably going to keep looking for it until a new or fixed version of GCC is installed (with the library that version of GCC requests).

About the second part: you're linking against somepath/libSomeLib.so, right? Then you need to add somepath to your library search path. You can do that 'temporarily' like this (in BASH):
export LD_LIBRARY_PATH=somepath# or, if you already have a LD_LIBRARY_PATH you want to preserve:export LD_LIBRARY_PATH=somepath:$LD_LIBRARY_PATH 

Since that's a relative path, it will only work from the directory containing somepath.



[edited by - Null and Void on July 11, 2003 3:10:53 PM]
Advertisement
Well, I installed gcc 2.95.2 according to the install directions, so I''m not sure how it could be broken (it wasn''t hard, just had to type a few commands with a few hours between each while it processed whatever, so I don''t think I messed it up). If that is the temporary way, what would be the permanent way (just put it in my bash profile? I''m not a complete linux n00b just never done any dev, admining, or installation on it before =-)
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
You could put it in your profile, and it''d be more permanent, yes. The ''real'' permanent way is to add the path to ld.so.conf, but that''s for system wide libraries, and you might as well be installing the library every time you build it in a system directory at that point. I just stick with the temporary solution (sometimes I add a ''run'' target to the make file of my test programs, so that it exports the correct path for me).

I''m not exactly sure what''s wrong with the GCC issue, so I can''t tell you exactly how to correct it. Finding out what libstdc++ versions you have installed could help (guessing here ). I haven''t built GCC by hand for a long time and back when I last did I didn''t have any problems with it, so I don''t have much practicle experience fixing its installation problems (or otherwise related issues, as this could be).

This topic is closed to new replies.

Advertisement