Compile and link to libdbus with debugging symbols

Simon McVittie smcv at
Wed Oct 25 11:09:01 UTC 2017

On Tue, 24 Oct 2017 at 13:21:24 -0600, Calvin Lee wrote:
> I'm trying to debug a d-bus program that uses libdbus, and can't seem
> to track down a bug without debugging symbols (which are mentioned in
> several error messages).

Your OS distribution should provide at least one of these, most-preferred

* a way to get "detached debugging symbols" understood by gdb
  in /usr/lib/debug (e.g. install the dbus-1-dbg package in older
  Debian or the libdbus-1-3-dbgsym package in newer Debian)

* a special version with debug symbols included, which can be used by
  installing it and possibly adding its directory to the LD_LIBRARY_PATH
  environment variable

* worst case, a way to recompile with debug symbols enabled (e.g.
  in very old Debian)

As you probably guessed from the number of times I mentioned Debian,
this is really more about your OS distribution than about dbus - Debian
happens to be the one I know most about. Different OS distributions do
this in different ways; they'll probably vaguely resemble one of the
various ways Debian has done this, because we're all basically using
the same technologies behind the scenes, but which one is recommended
and the precise details of how you achieve it vary. Please consult your
OS distribution's support channels for OS-specific help.

Building dbus from upstream source code is usually only a good idea
if your OS vendor doesn't provide it at all (if they do provide it,
you should usually prefer to use their version, which has been chosen,
configured and possibly patched to work well with the rest of their OS)
or if you *are* the OS vendor (in which case you are assumed to know
what you're doing).

If you are building from upstream source code, add CFLAGS="-O0 -g"
to the ./configure arguments (or add them to any CFLAGS you already
have) and use "make install" instead of "make install-strip". This is
the same as for any other software built using Autotools or following
the relevant parts of the GNU coding standards. In dbus >= 1.11.8,
adding --enable-debug=yes to the ./configure arguments is a slightly
easier-to-remember way to do the same thing.


More information about the dbus mailing list