Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Debugging shared C++ libs on Linux
Debugging shared C++ libs on Linux [message #204818] Wed, 14 November 2007 00:06 Go to next message
Eclipse UserFriend
Originally posted by: bje_web.comcast.net

I'm using the following versions of programs:
gcc version 4.1.1 20070105 (Red Hat 4.1.1-52)
Eclipse 3.3.0
CDT 4.0.1

I'm starting with a very simple C++ program, one library and an executing
program. When I build the library as a static debug version, the
debugging works great. When I build the library as a shared debug
version, the Run works fine but I get an ... 'error while loading shared
libraries' ... 'cannot open shared object file: No such file or directory'
when running Debug. I've set the following:

Debug Dialog:
Environment - Added path to shared library to start of LD_LIBRARY_PATH
Debugger > Shared Libraries - Added path

I've tried some of the other options but debug cannot find any that get me
running. I can run the debug version on the command line with the
LD_LIBRARY_PATH set.

I also tried running gdb from the command line. I set the LD_LIBRARY_PATH
but get the error while loading shared libraries error. I can set the
solib-search-path but still get the error. The only way around the error
when running gdb from the command line that I've found is to move the
libxx.so file into the directory I'm running gdb in.

I've searched the web for this issue. I see similar problems but cannot
find a solution to my problem. I'm starting with this example but really
want to use eclipse to debug some shared libraries in a pretty complex
environment.

Thanks for any suggestions.
Betty
Re: Debugging shared C++ libs on Linux [message #204911 is a reply to message #204818] Wed, 14 November 2007 20:20 Go to previous messageGo to next message
Alex Farberov is currently offline Alex FarberovFriend
Messages: 13
Registered: July 2009
Junior Member
Betty Evans wrote:
> I'm using the following versions of programs:
> gcc version 4.1.1 20070105 (Red Hat 4.1.1-52)
> Eclipse 3.3.0
> CDT 4.0.1
>
> I'm starting with a very simple C++ program, one library and an
> executing program. When I build the library as a static debug version,
> the debugging works great. When I build the library as a shared debug
> version, the Run works fine but I get an ... 'error while loading shared
> libraries' ... 'cannot open shared object file: No such file or
> directory' when running Debug. I've set the following:
> Debug Dialog:
> Environment - Added path to shared library to start of LD_LIBRARY_PATH
> Debugger > Shared Libraries - Added path
>
> I've tried some of the other options but debug cannot find any that get
> me running. I can run the debug version on the command line with the
> LD_LIBRARY_PATH set.
> I also tried running gdb from the command line. I set the
> LD_LIBRARY_PATH but get the error while loading shared libraries error.
> I can set the solib-search-path but still get the error. The only way
> around the error when running gdb from the command line that I've found
> is to move the libxx.so file into the directory I'm running gdb in.
>
> I've searched the web for this issue. I see similar problems but cannot
> find a solution to my problem. I'm starting with this example but
> really want to use eclipse to debug some shared libraries in a pretty
> complex environment.
>
> Thanks for any suggestions.
> Betty
>

Hi Betty,

Doesn't sound like your problem is related to Eclipse/CDT since you
cannot debug your shared library even via the command line of gdb.

If I understand you correctly, your program fails to run in gdb because
it cannot find a necessary shared object.

The first step would be to set the LD_LIBRARY_PATH to the location of
the shared object, then run "ldd <program>" on your executable and see
if your shared object's path has been resolved.

Another thing you could try is to set the environment variables
"LD_DEBUG=files,libs" and "LD_DEBUG_OUTPUT=my-ld-output.txt" and then
try to debug your program. You'll see a lot of output, through which
you'll have to search for your shared object's name. It should show you
the paths that the dynamic linker has tried to search in while trying to
find your shared library. Google LD_DEBUG for more info if you are
curious.

Hope it helps...
Re: Debugging shared C++ libs on Linux [message #204925 is a reply to message #204911] Wed, 14 November 2007 23:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bje_web.comcast.net

Alex

Thanks for the response. I found the problem. I wasn't setting the
LD_LIBRARY_PATH in my .cshrc file, just locally on the command line.
Previously I could only run gdb from the command line successfully if my
so file was in the same directory as my executable. When the gdb process
started, it didn't have the correct LD_LIBRARY_PATH. Once I set the
LD_LIBRARY_PATH in my .cshrc, both gdb and eclipse worked fine.

I thought that setting LD_LIBRARY_PATH in the Eclipse Run Dialog
Environment and/or the Debugger > Shared Libraries > Directories would
take care of everything. It looks like neither of these had any effect
when running in debug (interesting).

Thanks!
Betty
Re: Debugging shared C++ libs on Linux [message #204999 is a reply to message #204925] Thu, 15 November 2007 16:25 Go to previous messageGo to next message
Alex Farberov is currently offline Alex FarberovFriend
Messages: 13
Registered: July 2009
Junior Member
Betty Evans wrote:
> Alex
>
> Thanks for the response. I found the problem. I wasn't setting the
> LD_LIBRARY_PATH in my .cshrc file, just locally on the command line.
> Previously I could only run gdb from the command line successfully if my
> so file was in the same directory as my executable. When the gdb
> process started, it didn't have the correct LD_LIBRARY_PATH. Once I set
> the LD_LIBRARY_PATH in my .cshrc, both gdb and eclipse worked fine.
>
> I thought that setting LD_LIBRARY_PATH in the Eclipse Run Dialog
> Environment and/or the Debugger > Shared Libraries > Directories would
> take care of everything. It looks like neither of these had any effect
> when running in debug (interesting).
> Thanks!
> Betty
>

I never encountered problems with setting LD_LIBRARY_PATH either on the
command line or within eclipse. gdb works fine and loads shared
libraries using the path from LD_LIBRARY_PATH. I'm not sure why you had
to set it in your .cshrc. Perhaps something in your setup is launching
another shell (and thus losing the environment variable) prior to
executing the debugger.
Re: Debugging shared C++ libs on Linux [message #205275 is a reply to message #204999] Tue, 20 November 2007 22:55 Go to previous message
Eclipse UserFriend
Originally posted by: bje_web.comcast.net

Alex

Thanks for your help. I found where LD_LIBRARY_PATH was being reset. Now
all works great.

Betty
Previous Topic:Truncated output when using the Outline View with makefiles
Next Topic:CDT C Unit Testing Framework plug-in
Goto Forum:
  


Current Time: Thu Jun 13 14:12:45 GMT 2024

Powered by FUDForum. Page generated in 0.04541 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top