How to debug a program wrapped in a libtool script?

I have a project involving

  • shared libraries: mylib.so
  • (test) using these shared libraries, i.e.: test_mylib

When I try to run gdb on test_mylib , it prints:

 "test_mylib": not in executable format: File format not recognized 

When I use the real program ( .libs/test_mylib ) directly, it still complains:

 .libs/test_mylib: can't load library 'libhello.so.0' 

How to run gdb to debug my program?

+7
source share
2 answers

This is a problem that I encountered a couple of days ago, and there is no general answer to SO yet. Only special cases. Here is the answer I found on this page: http://www.gnu.org/software/libtool/manual/html_node/Debugging-executables.html

Until the program is installed, the system does not know where to look for common objects. They are usually located in the .libs subdirectory of the source folder.

Libtool creates a convenience script to enable debugging before the actual installation is completed (who wants to install the buggy software earlier, debug it after?)

Fortunately, the generated script provides for this helper:

 libtool --mode=execute gdb test_mylib 
+10
source

The solution recommended by libtool docs is to use static linking during development, as I described: Building a libtool application with static binding to local components

To do this, use the --disable-shared option ./configure script.

For example:

 ./configure --enable-debug --disable-shared 

Now the generated executable is a directly executable binary, not a libtool script.

This has the added benefit of reducing assembly time by about half.

+4
source

All Articles