交叉编译GDB

交叉编译GDB

GDB是一款强大的调试工具,不多介绍了

  1. 下载GDB源码,点击下载
  2. 解压文件tar xf gdb-7.9.tar.gz
  3. 配置编译
    编写编译脚本
#!/bin/bash
./configure \
    CC=/opt/mipsel-gcc472-glibc216-mips32/bin/mipsel-linux-gcc --enable-static \
    CFLAGS="-g -O2 -I/disk1/home/xllv/workspace/gdb/termcap-1.3.1/out/include" \
    LDFLAGS=-L/disk1/home/xllv/workspace/gdb/termcap-1.3.1/out/lib \
    --prefix=/disk1/home/xllv/workspace/gdb/gdb-7.9/output/mips \
    --target=mipsel-linux \
    --host=mipsel-linux \
    --program-prefix=mipsel-linux-
make
make install

--target目标平台 当前制定为mipsel-linux, 或者arm-linux
--host程序运行的机器,注意这个值会影响程序里面的ar等命令的前缀,如上述, 指定host为mipsel-linux,那么程序文件的makefile 里面的就会出现AR=mipsel-linux-ar
--program-prefix 指定生成gdb, gdbserver 名字前缀
--prefix指定 make install 的安装目录
CC 指定交叉编译工具
--enable-static 静态加载库
注意需要指定环境变量,export PATH=$PATH:/opt/mipsel-gcc472-glibc216-mips32/bin/mipsel-linux-gcc, 编译过程中会使用到mipsel-linux-ar, mipsel-linux-strip等等

你可能感兴趣的:(gdb,交叉编译)