1 # Linux — Building and Debugging GTK
3 Sometimes installing the debug packages for gtk and glib isn't quite enough.
4 (For instance, if the artifacts from -O2 are driving you bonkers in gdb, you
5 might want to rebuild with -O0.)
6 Here's how to build from source and use your local version without installing
13 On Ubuntu, to download and build glib and gtk suitable for debugging:
15 1. If you don't have a gpg key yet, generate one with `gpg --gen-key`.
16 2. Create file `~/.devscripts` containing `DEBSIGN_KEYID=yourkey`, e.g.
17 `DEBSIGN_KEYID=CC91A262` (See
18 http://www.debian.org/doc/maint-guide/ch-build.en.html)
19 3. If you're on a 32 bit system, do:
25 # Workaround for "E: Build-dependencies for glib2.0 could not be satisfied"
26 # See also https://bugs.launchpad.net/ubuntu/+source/apt/+bug/245068
27 sudo apt-get install libgamin-dev
28 sudo apt-get build-dep glib2.0 gtk+2.0
32 apt-get source glib2.0 gtk+2.0
34 DEB_BUILD_OPTIONS="nostrip noopt debug" debuild
36 DEB_BUILD_OPTIONS="nostrip noopt debug" debuild
39 This should take about an hour. If it gets stuck waiting for a zombie,
40 you may have to kill its closest parent (the makefile uses subshells,
41 and bash seems to get confused). When I did this, it continued successfully.
43 At the very end, it will prompt you for the passphrase for your gpg key.
45 Then, to run an app with those libraries, do e.g.
47 export LD_LIBRARY_PATH=$HOME/mylibs/gtk+2.0-2.16.1/debian/install/shared/usr/lib:$HOME/mylibs/gtk+2.0-2.20.1/debian/install/shared/usr/lib
49 gdb ignores that variable, so in the debugger, you would have to do something like
51 set solib-search-path $HOME/mylibs/gtk+2.0-2.16.1/debian/install/shared/usr/lib:$HOME/mylibs/gtk+2.0-2.20.1/debian/install/shared/usr/lib
53 See also http://sources.redhat.com/gdb/current/onlinedocs/gdb_17.html
57 If you're on a 64 bit system, you can do the above on a 32
58 bit system, and copy the result. Or try one of the following:
60 ### Building your own GTK
63 apt-get source glib-2.0 gtk+-2.0
65 export CFLAGS='-m32 -g'
66 export LDFLAGS=-L/usr/lib32
67 export LD_LIBRARY_PATH=/work/32/lib
68 export PKG_CONFIG_PATH=/work/32/lib/pkgconfig
71 setarch i386 ./configure --prefix=/work/32 --enable-debug=yes
74 setarch i386 ./configure --prefix=/work/32 --enable-debug=yes --without-libtiff
79 _Note: Evan tried this and didn't get any debug libs at the end._
81 Or you could try this instead:
87 sudo apt-get build-dep ia32-libs
91 apt-get source ia32-libs
93 DEB_BUILD_OPTIONS="nostrip noopt debug" debuild
96 By default, this just grabs and unpacks prebuilt libraries; see
97 ia32-libs-2.7ubuntu6/fetch-and-build which documents a BUILD variable which
98 would force actual building. This would take way longer, since it builds dozens
99 of libraries. I haven't tried it yet.
103 debuild may fail with
106 gpg: [stdin]: clearsign failed: secret key not available
107 debsign: gpg error occurred! Aborting....
110 if you forget to create `~/.devscripts` with the right contents.
112 The build may fail with a `FAIL: abicheck.sh` if gold is your system linker. Use