blob: dea311ef8695ee9888ed79fbc411c60692c49e80 [file] [log] [blame] [view]
andybonsad92aa32015-08-31 02:27:441# Linux — Building and Debugging GTK
andybons3322f762015-08-24 21:37:092
3Sometimes 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
5might want to rebuild with -O0.)
andybonsad92aa32015-08-31 02:27:446Here's how to build from source and use your local version without installing
7it.
8
9[TOC]
andybons3322f762015-08-24 21:37:0910
11## 32-bit systems
12
13On Ubuntu, to download and build glib and gtk suitable for debugging:
14
andybonsad92aa32015-08-31 02:27:44151. If you don't have a gpg key yet, generate one with `gpg --gen-key`.
162. 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)
193. If you're on a 32 bit system, do:
andybons3322f762015-08-24 21:37:0920
andybonsad92aa32015-08-31 02:27:4421 ```shell
22 #!/bin/sh
23 set -x
24 set -e
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
29 rm -rf ~/mylibs
30 mkdir ~/mylibs
31 cd ~/mylibs
32 apt-get source glib2.0 gtk+2.0
33 cd glib2.0*
34 DEB_BUILD_OPTIONS="nostrip noopt debug" debuild
35 cd ../gtk+2.0*
36 DEB_BUILD_OPTIONS="nostrip noopt debug" debuild
37 ```
andybons3322f762015-08-24 21:37:0938
andybonsad92aa32015-08-31 02:27:4439This should take about an hour. If it gets stuck waiting for a zombie,
andybons3322f762015-08-24 21:37:0940you may have to kill its closest parent (the makefile uses subshells,
andybonsad92aa32015-08-31 02:27:4441and bash seems to get confused). When I did this, it continued successfully.
andybons3322f762015-08-24 21:37:0942
43At the very end, it will prompt you for the passphrase for your gpg key.
44
45Then, to run an app with those libraries, do e.g.
andybonsad92aa32015-08-31 02:27:4446
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
andybons3322f762015-08-24 21:37:0948
49gdb ignores that variable, so in the debugger, you would have to do something like
andybonsad92aa32015-08-31 02:27:4450
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
andybons3322f762015-08-24 21:37:0952
53See also http://sources.redhat.com/gdb/current/onlinedocs/gdb_17.html
54
55## 64-bit systems
56
andybonsad92aa32015-08-31 02:27:4457If you're on a 64 bit system, you can do the above on a 32
andybons3322f762015-08-24 21:37:0958bit system, and copy the result. Or try one of the following:
59
60### Building your own GTK
61
andybonsad92aa32015-08-31 02:27:4462```shell
andybons3322f762015-08-24 21:37:0963apt-get source glib-2.0 gtk+-2.0
64
65export CFLAGS='-m32 -g'
66export LDFLAGS=-L/usr/lib32
67export LD_LIBRARY_PATH=/work/32/lib
68export PKG_CONFIG_PATH=/work/32/lib/pkgconfig
69
70# glib
71setarch i386 ./configure --prefix=/work/32 --enable-debug=yes
72
73# gtk
74setarch i386 ./configure --prefix=/work/32 --enable-debug=yes --without-libtiff
75```
76
andybons3322f762015-08-24 21:37:0977### ia32-libs
andybonsad92aa32015-08-31 02:27:4478
andybons3322f762015-08-24 21:37:0979_Note: Evan tried this and didn't get any debug libs at the end._
80
81Or you could try this instead:
andybonsad92aa32015-08-31 02:27:4482
andybons3322f762015-08-24 21:37:0983```
84#!/bin/sh
85set -x
86set -e
87sudo apt-get build-dep ia32-libs
88rm -rf ~/mylibs
89mkdir ~/mylibs
90cd ~/mylibs
91apt-get source ia32-libs
92cd ia32-libs*
93DEB_BUILD_OPTIONS="nostrip noopt debug" debuild
94```
95
96By default, this just grabs and unpacks prebuilt libraries; see
andybonsad92aa32015-08-31 02:27:4497ia32-libs-2.7ubuntu6/fetch-and-build which documents a BUILD variable which
98would force actual building. This would take way longer, since it builds dozens
99of libraries. I haven't tried it yet.
andybons3322f762015-08-24 21:37:09100
101#### Possible Issues
102
103debuild may fail with
andybonsad92aa32015-08-31 02:27:44104
andybons3322f762015-08-24 21:37:09105```
106gpg: [stdin]: clearsign failed: secret key not available
107debsign: gpg error occurred! Aborting....
108```
andybons3322f762015-08-24 21:37:09109
andybonsad92aa32015-08-31 02:27:44110if you forget to create `~/.devscripts` with the right contents.
111
112The build may fail with a `FAIL: abicheck.sh` if gold is your system linker. Use
113ld instead.