| OLD | NEW |
| 1 # Introduction | 1 # Linux — Building and Debugging GTK |
| 2 | 2 |
| 3 Sometimes installing the debug packages for gtk and glib isn't quite enough. | 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 | 4 (For instance, if the artifacts from -O2 are driving you bonkers in gdb, you |
| 5 might want to rebuild with -O0.) | 5 might want to rebuild with -O0.) |
| 6 Here's how to build from source and use your local version without installing it
. | 6 Here's how to build from source and use your local version without installing |
| 7 it. |
| 8 |
| 9 [TOC] |
| 7 | 10 |
| 8 ## 32-bit systems | 11 ## 32-bit systems |
| 9 | 12 |
| 10 On Ubuntu, to download and build glib and gtk suitable for debugging: | 13 On Ubuntu, to download and build glib and gtk suitable for debugging: |
| 11 | 14 |
| 12 1. If you don't have a gpg key yet, generate one with gpg --gen-key. | 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: |
| 13 | 20 |
| 14 2. Create file ~/.devscripts containing DEBSIGN\_KEYID=yourkey, e.g. | 21 ```shell |
| 15 DEBSIGN\_KEYID=CC91A262 | 22 #!/bin/sh |
| 16 (See http://www.debian.org/doc/maint-guide/ch-build.en.html | 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 ``` |
| 17 | 38 |
| 18 3. If you're on a 32 bit system, do: | 39 This should take about an hour. If it gets stuck waiting for a zombie, |
| 19 ``` | |
| 20 #!/bin/sh | |
| 21 set -x | |
| 22 set -e | |
| 23 # Workaround for "E: Build-dependencies for glib2.0 could not be satisfied" | |
| 24 # See also https://bugs.launchpad.net/ubuntu/+source/apt/+bug/245068 | |
| 25 sudo apt-get install libgamin-dev | |
| 26 sudo apt-get build-dep glib2.0 gtk+2.0 | |
| 27 rm -rf ~/mylibs | |
| 28 mkdir ~/mylibs | |
| 29 cd ~/mylibs | |
| 30 apt-get source glib2.0 gtk+2.0 | |
| 31 cd glib2.0* | |
| 32 DEB_BUILD_OPTIONS="nostrip noopt debug" debuild | |
| 33 cd ../gtk+2.0* | |
| 34 DEB_BUILD_OPTIONS="nostrip noopt debug" debuild | |
| 35 ``` | |
| 36 This should take about an hour. If it gets stuck waiting for a zombie, | |
| 37 you may have to kill its closest parent (the makefile uses subshells, | 40 you may have to kill its closest parent (the makefile uses subshells, |
| 38 and bash seems to get confused). When I did this, it continued successfully. | 41 and bash seems to get confused). When I did this, it continued successfully. |
| 39 | 42 |
| 40 At the very end, it will prompt you for the passphrase for your gpg key. | 43 At the very end, it will prompt you for the passphrase for your gpg key. |
| 41 | 44 |
| 42 Then, to run an app with those libraries, do e.g. | 45 Then, to run an app with those libraries, do e.g. |
| 43 ``` | 46 |
| 44 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 | 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 |
| 45 ``` | |
| 46 | 48 |
| 47 gdb ignores that variable, so in the debugger, you would have to do something li
ke | 49 gdb ignores that variable, so in the debugger, you would have to do something li
ke |
| 48 ``` | 50 |
| 49 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 | 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 |
| 50 ``` | |
| 51 | 52 |
| 52 See also http://sources.redhat.com/gdb/current/onlinedocs/gdb_17.html | 53 See also http://sources.redhat.com/gdb/current/onlinedocs/gdb_17.html |
| 53 | 54 |
| 54 ## 64-bit systems | 55 ## 64-bit systems |
| 55 | 56 |
| 56 If you're on a 64 bit systems, you can do the above on a 32 | 57 If you're on a 64 bit system, you can do the above on a 32 |
| 57 bit system, and copy the result. Or try one of the following: | 58 bit system, and copy the result. Or try one of the following: |
| 58 | 59 |
| 59 ### Building your own GTK | 60 ### Building your own GTK |
| 60 | 61 |
| 61 ``` | 62 ```shell |
| 62 apt-get source glib-2.0 gtk+-2.0 | 63 apt-get source glib-2.0 gtk+-2.0 |
| 63 | 64 |
| 64 export CFLAGS='-m32 -g' | 65 export CFLAGS='-m32 -g' |
| 65 export LDFLAGS=-L/usr/lib32 | 66 export LDFLAGS=-L/usr/lib32 |
| 66 export LD_LIBRARY_PATH=/work/32/lib | 67 export LD_LIBRARY_PATH=/work/32/lib |
| 67 export PKG_CONFIG_PATH=/work/32/lib/pkgconfig | 68 export PKG_CONFIG_PATH=/work/32/lib/pkgconfig |
| 68 | 69 |
| 69 # glib | 70 # glib |
| 70 setarch i386 ./configure --prefix=/work/32 --enable-debug=yes | 71 setarch i386 ./configure --prefix=/work/32 --enable-debug=yes |
| 71 | 72 |
| 72 # gtk | 73 # gtk |
| 73 setarch i386 ./configure --prefix=/work/32 --enable-debug=yes --without-libtiff | 74 setarch i386 ./configure --prefix=/work/32 --enable-debug=yes --without-libtiff |
| 74 ``` | 75 ``` |
| 75 | 76 |
| 77 ### ia32-libs |
| 76 | 78 |
| 77 ### ia32-libs | |
| 78 _Note: Evan tried this and didn't get any debug libs at the end._ | 79 _Note: Evan tried this and didn't get any debug libs at the end._ |
| 79 | 80 |
| 80 Or you could try this instead: | 81 Or you could try this instead: |
| 82 |
| 81 ``` | 83 ``` |
| 82 #!/bin/sh | 84 #!/bin/sh |
| 83 set -x | 85 set -x |
| 84 set -e | 86 set -e |
| 85 sudo apt-get build-dep ia32-libs | 87 sudo apt-get build-dep ia32-libs |
| 86 rm -rf ~/mylibs | 88 rm -rf ~/mylibs |
| 87 mkdir ~/mylibs | 89 mkdir ~/mylibs |
| 88 cd ~/mylibs | 90 cd ~/mylibs |
| 89 apt-get source ia32-libs | 91 apt-get source ia32-libs |
| 90 cd ia32-libs* | 92 cd ia32-libs* |
| 91 DEB_BUILD_OPTIONS="nostrip noopt debug" debuild | 93 DEB_BUILD_OPTIONS="nostrip noopt debug" debuild |
| 92 ``` | 94 ``` |
| 93 | 95 |
| 94 By default, this just grabs and unpacks prebuilt libraries; see | 96 By default, this just grabs and unpacks prebuilt libraries; see |
| 95 ia32-libs-2.7ubuntu6/fetch-and-build which documents a BUILD | 97 ia32-libs-2.7ubuntu6/fetch-and-build which documents a BUILD variable which |
| 96 variable which would force actual building. | 98 would force actual building. This would take way longer, since it builds dozens |
| 97 This would take way longer, since it builds dozens of libraries. | 99 of libraries. I haven't tried it yet. |
| 98 I haven't tried it yet. | |
| 99 | 100 |
| 100 #### Possible Issues | 101 #### Possible Issues |
| 101 | 102 |
| 102 debuild may fail with | 103 debuild may fail with |
| 104 |
| 103 ``` | 105 ``` |
| 104 gpg: [stdin]: clearsign failed: secret key not available | 106 gpg: [stdin]: clearsign failed: secret key not available |
| 105 debsign: gpg error occurred! Aborting.... | 107 debsign: gpg error occurred! Aborting.... |
| 106 ``` | 108 ``` |
| 107 if you forget to create ~/.devscripts with the right contents. | |
| 108 | 109 |
| 109 The build may fail with a "FAIL: abicheck.sh" if gold is your system | 110 if you forget to create `~/.devscripts` with the right contents. |
| 110 linker. Use ld instead. | 111 |
| 112 The build may fail with a `FAIL: abicheck.sh` if gold is your system linker. Use |
| 113 ld instead. |
| OLD | NEW |