| 1 | = Debug the code = |
| 2 | |
| 3 | Since the switch to shared libraries we use [http://www.gnu.org/software/libtool/ libtool] to do the compiling and linking. |
| 4 | |
| 5 | Due to its inner workings, the true executable is not generated until |
| 6 | {{{ |
| 7 | make install |
| 8 | }}} |
| 9 | is executed. If you check on e.g. ./src/molecuilder in your build directory after compilation you will notice that it is just a shell script pointing to some stuff residing in '''.libs''' in the same directory. |
| 10 | |
| 11 | Hence, debugging this shell script will not work, but make [http://www.gnu.org/software/gdb/ gdb] cry out that it does not recognize the executable's format: |
| 12 | {{{ |
| 13 | $> gdb ./src/molecuilder |
| 14 | GNU gdb (GDB) 7.1-ubuntu |
| 15 | Copyright (C) 2010 Free Software Foundation, Inc. |
| 16 | License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> |
| 17 | This is free software: you are free to change and redistribute it. |
| 18 | There is NO WARRANTY, to the extent permitted by law. Type "show copying" |
| 19 | and "show warranty" for details. |
| 20 | This GDB was configured as "x86_64-linux-gnu". |
| 21 | For bug reporting instructions, please see: |
| 22 | <http://www.gnu.org/software/gdb/bugs/>... |
| 23 | "/mnt.auto/bespin/heber/workspace_C/molecuilder/debug64/src/molecuilder": not in executable format: File format not recognized |
| 24 | (gdb) q |
| 25 | }}} |
| 26 | |
| 27 | Instead, execute: |
| 28 | {{{ |
| 29 | libtool --mode=execute gdb --args ./src/molecuilder -v [some more options ...] |
| 30 | }}} |
| 31 | |
| 32 | You may also set your own alias in '''~/.bashrc''' to ease the typing, just add the following line to the file |
| 33 | {{{ |
| 34 | alias debug='libtool --mode=execute gdb --args' |
| 35 | }}} |