libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Profiling a library built with libtool


From: Benoit SIGOURE
Subject: Re: Profiling a library built with libtool
Date: Fri, 13 Jul 2007 17:16:00 +0200

On Jul 13, 2007, at 4:39 PM, Joseph Wakeling wrote:

I have a small library which is built using the GNU autotools. It also
includes some executable programs which use the main library.  I would
like to profile the performance using gprof or another tool but have
been having trouble working out how to do so. I tried simply adding -p
to the CFLAGS but the resulting gmon.out appeared to contain no data
(e.g. running gprof on the executable or on the .la file resulted in an error, "not in executable format", while running it on one of the object
files produced no information).

I wonder if someone could give me a brief run-through on how to profile
the library---what options I need to place in the autotools-related
files and when using ./configure, and how to use gprof effectively on
the library once built.


Hello Joseph,
when using libtool, the `binary' produced in the build directory is in fact a wrapper shell script that does some setup and then runs the real binary. This is required because your executable probably depends on uninstalled libraries and the script does some magic before running it (such as, typically, setting the LD_LIBRARY_PATH if you're on GNU/Linux).

If, say, I have a bin_PROGRAMS `foo' that depends on a lib_LTLIBRARIES `libfoo.la', this is what I have:

$ file foo libfoo.la
foo:       Bourne shell script text executable
libfoo.la: ASCII English text

The .la file is a piece of shell script that contains information useful to libtool.

Now the answer to your question is to ask libtool to run gprof (or gdb) for you:
./libtool --mode=execute gprof ./foo

Cheers,

--
Benoit Sigoure aka Tsuna
EPITA Research and Development Laboratory


Attachment: PGP.sig
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]