参考文章:https://github.com/cfenollosa/os-tutorial/tree/master/14-checkpoint
1. 安装
按照下面的命令,进行源码安装。
cd /tmp/src
curl -O http://ftp.rediris.es/mirror/GNU/gdb/gdb-7.8.tar.gz
tar xf gdb-7.8.tar.gz
mkdir gdb-build
cd gdb-build
export PREFIX="/usr/local/i386elfgcc"
export TARGET=i386-elf
../gdb-7.8/configure --target="$TARGET" --prefix="$PREFIX" --program-prefix=i386-elf-
make
make install
2. 解决错误
2.1 问题1
可能会出现以下几种错误,下面进行解决。
make[3]: Nothing to be done for 'info'.
make[3]: Leaving directory '/tmp/src/gdb-build/bfd/po'
make[3]: Entering directory '/tmp/src/gdb-build/bfd'
make[3]: Nothing to be done for 'info-am'.
make[3]: Leaving directory '/tmp/src/gdb-build/bfd'
Makefile:1652: recipe for target 'info-recursive' failed
make[2]: *** [info-recursive] Error 1
make[2]: Leaving directory '/tmp/src/gdb-build/bfd'
Makefile:2597: recipe for target 'all-bfd' failed
make[1]: *** [all-bfd] Error 2
make[1]: Leaving directory '/tmp/src/gdb-build'
Makefile:831: recipe for target 'all' failed
make: *** [all] Error 2
根据https://www.linuxquestions.org/questions/linux-from-scratch-13/binutils-make-error-lfs-7-7-a-4175538162/的讨论可知,这是由于缺少makeinfo这个包导致的。
我的是Ubuntu系统,故可以使用apt-get
直接安装。需要注意的是:安装包名称为texinfo,而不是makeinfo
sudo apt-get install texinfo
2.2 问题2
checking for library containing tgetent... no
configure: error: no termcap library found
Makefile:8639: recipe for target 'configure-gdb' failed
make[1]: *** [configure-gdb] Error 1
make[1]: Leaving directory '/tmp/src/gdb-build'
Makefile:832: recipe for target 'all' failed
make: *** [all] Error 2
根据https://superuser.com/questions/489304/why-cant-i-find-termcap-library-when-i-build-gdb的讨论,原因应该是缺少termcap库,通过源码安装即可。但是我解决的办法是answer1:
sudo apt-get install libncurses5-dev