目录
前期准备:
开始编译:
配置编译环境:
配置交叉编译工具链:
创建交叉编译产物的目录:
termcap:
ncurses:
gmp:
gdb:
编译产物:
前期准备:
pc机系统:ubuntu系统
目标板的编译工具链:arm-openwrt-linux-gcc
嵌入式Linux目标板:R328
开始编译:
编译gdb工具,首先需要下载gdb的源代码,以及它依赖的其他开源库源码,包括ncurses,termcap和gmp。
配置编译环境:
$ sudo apt-get install bison flex expect-dev build-essential m4 autoconf automake texi2html
配置交叉编译工具链:
$ export PATH=$PATH:/home/guofeng/Workspace/myself/matrix/matrix/toolchains/r328-toolchain/toolchain-sunxi-musl/toolchain/bin
$ export STAGING_DIR=$STAGING_DIR:/home/guofeng/Workspace/myself/matrix/matrix/toolchains/r328-toolchain/toolchain-sunxi-musl/toolchain/bin
创建交叉编译产物的目录:
$ mkdir /home/guofeng/Workspace/gdb_cross_compile
termcap:
下载源码:
$ wget https://ftp.gnu.org/gnu/termcap/termcap-1.3.1.tar.gz
解压后,进入到termcap的目录中
$ ./configure --prefix=/home/guofeng/Workspace/gdb_cross_compile/
$ vim Makefile
CC = gcc
AR = ar
RANLIB = ranlib
修改为:
CC = arm-openwrt-linux-gcc
AR = arm-openwrt-linux-ar
RANLIB = arm-openwrt-linux-ranlib
然后make,make install,会将交叉编译后的h文件,库文件,文档文件,copy到gdb_cross_compile文件夹的include,lib,info中。
make install会提示错误,它操作了/usr/include目录,但是又没有权限,直接忽略就好。
guofeng@ubuntu:~/Workspace/gdb_cross_compile/termcap-1.3.1$ make
arm-openwrt-linux-gcc -c -DHAVE_STRING_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DTERMCAP_FILE=\"/etc/termcap\" -I. -I. -g termcap.c
arm-openwrt-linux-gcc -c -DHAVE_STRING_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DTERMCAP_FILE=\"/etc/termcap\" -I. -I. -g tparam.c
tparam.c: In function 'memory_out':
tparam.c:51:3: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
write (2, "virtual memory exhausted\n", 25);
^~~~~
arm-openwrt-linux-gcc -c -DHAVE_STRING_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DTERMCAP_FILE=\"/etc/termcap\" -I. -I. -g version.c
arm-openwrt-linux-ar rc libtermcap.a termcap.o tparam.o version.o
arm-openwrt-linux-ranlib libtermcap.a
guofeng@ubuntu:~/Workspace/gdb_cross_compile/termcap-1.3.1$ make install
/bin/sh ./mkinstalldirs /home/guofeng/Workspace/gdb_cross_compile//lib \
/home/guofeng/Workspace/gdb_cross_compile//include /home/guofeng/Workspace/gdb_cross_compile//info
mkdir /home/guofeng/Workspace/gdb_cross_compile/lib
mkdir /home/guofeng/Workspace/gdb_cross_compile/include
mkdir /home/guofeng/Workspace/gdb_cross_compile/info
/usr/bin/install -c -m 644 libtermcap.a /home/guofeng/Workspace/gdb_cross_compile//lib/libtermcap.a
arm-openwrt-linux-ranlib /home/guofeng/Workspace/gdb_cross_compile//lib/libtermcap.a
cd .; /usr/bin/install -c -m 644 termcap.h /home/guofeng/Workspace/gdb_cross_compile//include/termcap.h
cd .; test -z "/usr/include" || \
/usr/bin/install -c -m 644 termcap.h /usr/include/termcap.h
/usr/bin/install: cannot remove '/usr/include/termcap.h': Permission denied
make: [Makefile:78: install] Error 1 (ignored)
cd .; for f in termcap.info*; \
do /usr/bin/install -c -m 644 $f /home/guofeng/Workspace/gdb_cross_compile//info/$f; done
guofeng@ubuntu:~/Workspace/gdb_cross_compile$ tree include/
include/
└── termcap.h
0 directories, 1 file
guofeng@ubuntu:~/Workspace/gdb_cross_compile$ tree lib/
lib/
└── libtermcap.a
0 directories, 1 file
guofeng@ubuntu:~/Workspace/gdb_cross_compile$ tree info/
info/
├── termcap.info
├── termcap.info-1
├── termcap.info-2
├── termcap.info-3
└── termcap.info-4
0 directories, 5 files
ncurses:
$ ./configure --prefix=/home/guofeng/Workspace/gdb_cross_compile/ --host=arm-openwrt-linux --with-shared
$ make
$ make install
$ wget https://ftp.gnu.org/gnu/ncurses/ncurses-6.4.tar.gz
guofeng@ubuntu:~/Workspace/gdb_cross_compile/ncurses-6.4$ ./configure --prefix=/home/guofeng/Workspace/gdb_cross_compile/ --host=arm-openwrt-linux --with-shared
configure: WARNING: If you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used.
checking for ggrep... no
checking for grep... grep
checking for egrep... grep -E
Configuring NCURSES 6.4 ABI 6 (Wed Sep 6 16:01:06 CST 2023)
checking for package version... 6.4
checking for package patch date... 20221231
checking build system type... x86_64-pc-linux-gnu
checking host system type... arm-openwrt-linux-gnu
checking target system type... arm-openwrt-linux-gnu
Configuring for linux-gnu
checking for fgrep... grep -F
checking for prefix... /home/guofeng/Workspace/gdb_cross_compile/
checking for arm-openwrt-linux-gnatgcc... no
checking for arm-openwrt-linux-gcc... arm-openwrt-linux-gcc
checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... yes
checking for executable suffix...
checking for object suffix... o
checking whether we are using the GNU C compiler... yes
checking whether arm-openwrt-linux-gcc accepts -g... yes
checking version of arm-openwrt-linux-gcc... .
checking if this is really Intel C compiler... no
checking if this is really Clang C compiler... no
checking for arm-openwrt-linux-gcc option to accept ANSI C... none needed
checking $CFLAGS variable... ok
checking $CC variable... ok
checking how to run the C preprocessor... arm-openwrt-linux-gcc -E
checking whether arm-openwrt-linux-gcc needs -traditional... no
checking whether arm-openwrt-linux-gcc understands -c and -o together... yes
checking if you want to ensure bool is consistent with C++... yes
checking for arm-openwrt-linux-g++... arm-openwrt-linux-g++
guofeng@ubuntu:~/Workspace/gdb_cross_compile/ncurses-6.4$ make
( cd man && make DESTDIR="" RPATH_LIST="/home/guofeng/Workspace/gdb_cross_compile//lib" all )
make[1]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/ncurses-6.4/man'
/bin/sh ./MKterminfo.sh ./terminfo.head ./../include/Caps ./../include/Caps-ncurses ./terminfo.tail >terminfo.5
make[1]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/ncurses-6.4/man'
( cd include && make DESTDIR="" RPATH_LIST="/home/guofeng/Workspace/gdb_cross_compile//lib" all )
make[1]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/ncurses-6.4/include'
cat curses.head >curses.h
AWK=mawk /bin/sh ./MKkey_defs.sh ./Caps ./Caps-ncurses >>curses.h
/bin/sh -c 'if test "0" = "1" ; then cat ./curses.events >>curses.h ; fi'
/bin/sh -c 'if test "chtype" = "cchar_t" ; then cat ./curses.wide >>curses.h ; fi'
cat ./curses.tail >>curses.h
/bin/sh ./MKhashsize.sh ./Caps ./Caps-ncurses >hashsize.h
AWK=mawk /bin/sh ./MKncurses_def.sh ./ncurses_defs >ncurses_def.h
AWK=mawk /bin/sh ./MKparametrized.sh ./Caps ./Caps-ncurses >parametrized.h
touch config.h
mawk -f MKterm.h.awk ./Caps ./Caps-ncurses > term.h
/bin/sh ./edit_cfg.sh ../include/ncurses_cfg.h term.h
** edit: HAVE_TCGETATTR 1
** edit: HAVE_TERMIOS_H 1
** edit: HAVE_TERMIO_H 0
** edit: BROKEN_LINKER 0
make[1]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/ncurses-6.4/include'
( cd ncurses && make DESTDIR="" RPATH_LIST="/home/guofeng/Workspace/gdb_cross_compile//lib" all )
make[1]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/ncurses-6.4/ncurses'
mawk -f ./tinfo/MKcodes.awk bigstrings=1 ../include/Caps ../include/Caps-ncurses >codes.c
gcc -o make_hash -DHAVE_CONFIG_H -DUSE_BUILD_CC -I../ncurses -I. -I../include -I./../include ./tinfo/make_hash.c
/bin/sh -e ./tinfo/MKcaptab.sh mawk 1 ./tinfo/MKcaptab.awk ../include/Caps ../include/Caps-ncurses > comp_captab.c
/bin/sh -e ./tinfo/MKuserdefs.sh mawk 1 ../include/Caps ../include/Caps-ncurses > comp_userdefs.c
/bin/sh -e ./tty/MKexpanded.sh "arm-openwrt-linux-gcc -E" -DHAVE_CONFIG_H -DBUILDING_NCURSES -I../ncurses -I. -I../include -DNDEBUG > expanded.c
/bin/sh -e ./tinfo/MKfallback.sh /home/guofeng/Workspace/gdb_cross_compile//share/terminfo ../misc/terminfo.src "tic" "infocmp" >fallback.c
FGREP="grep -F" /bin/sh -e ./base/MKlib_gen.sh "arm-openwrt-linux-gcc -E -DHAVE_CONFIG_H -DBUILDING_NCURSES -I../ncurses -I. -I../include -DNDEBUG" "mawk" generated <../include/curses.h >lib_gen.c
.. adding -P option to work around arm-openwrt-linux-gcc 6.4.1
AWK=mawk /bin/sh ./tinfo/MKkeys_list.sh ../include/Caps ../include/Caps-ncurses | LC_ALL=C sort >keys.list
mawk -f ./base/MKkeyname.awk bigstrings=1 keys.list > lib_keyname.c
FGREP="grep -F" /bin/sh -e ./base/MKlib_gen.sh "arm-openwrt-linux-gcc -E -DHAVE_CONFIG_H -DBUILDING_NCURSES -I../ncurses -I. -I../include -DNDEBUG" "mawk" implemented <../include/curses.h >link_test.c
.. adding -P option to work around arm-openwrt-linux-gcc 6.4.1
mawk -f ./tinfo/MKnames.awk bigstrings=1 ../include/Caps ../include/Caps-ncurses >names.c
echo | mawk -f ./base/MKunctrl.awk bigstrings=1 >unctrl.c
gcc -o make_keys -DHAVE_CONFIG_H -DUSE_BUILD_CC -I../ncurses -I. -I../include -I./../include ./tinfo/make_keys.c
./make_keys keys.list > init_keytry.h
arm-openwrt-linux-gcc -DHAVE_CONFIG_H -DBUILDING_NCURSES -I../ncurses -I. -I../include -DNDEBUG -O2 --param max-inline-insns-single=1200 -fPIC -c ../ncurses/./tty/hardscroll.c -o ../obj_s/hardscroll.o
arm-openwrt-linux-gcc -DHAVE_CONFIG_H -DBUILDING_NCURSES -I../ncurses -I. -I../include -DNDEBUG -O2 --param max-inline-insns-single=1200 -fPIC -c ../ncurses/./tty/hashmap.c -o ../obj_s/hashmap.o
arm-openwrt-linux-gcc -DHAVE_CONFIG_H -DBUILDING_NCURSES -I../ncurses -I. -I../include -DNDEBUG -O2 --param max-inline-insns-single=1200 -fPIC -c ../ncurses/./base/lib_addch.c -o ../obj_s/lib_addch.o
arm-openwrt-linux-gcc -DHAVE_CONFIG_H -DBUILDING_NCURSES -I../ncurses -I. -I../include -DNDEBUG -O2 --param max-inline-insns-single=1200 -fPIC -c ../ncurses/./base/lib_addstr.c -o ../obj_s/lib_addstr.o
arm-openwrt-linux-gcc -DHAVE_CONFIG_H -DBUILDING_NCURSES -I../ncurses -I. -I../include -DNDEBUG -O2 --param max-inline-insns-single=1200 -fPIC -c ../ncurses/./base/lib_beep.c -o ../obj_s/lib_beep.o
arm-openwrt-linux-gcc -DHAVE_CONFIG_H -DBUILDING_NCURSES -I../ncurses -I. -I../include -DNDEBUG -O2 --param max-inline-insns-single=1200 -fPIC -c ../ncurses/./base/lib_bkgd.c -o ../obj_s/lib_bkgd.o
arm-openwrt-linux-gcc -DHAVE_CONFIG_H -DBUILDING_NCURSES -I../ncurses -I. -I../include -DNDEBUG -O2 --param max-inline-insns-single=1200 -fPIC -c ../ncurses/./base/lib_box.c -o ../obj_s/lib_box.o
arm-openwrt-linux-gcc -DHAVE_CONFIG_H -DBUILDING_NCURSES -I../ncurses -I. -I../include -DNDEBUG -O2 --param max-inline-insns-single=1200 -fPIC -c ../ncurses/./base/lib_chgat.c -o ../obj_s/lib_chgat.o
arm-openwrt-linux-gcc -DHAVE_CONFIG_H -DBUILDING_NCURSES -I../ncurses -I. -I../include -DNDEBUG -O2 --param max-inline-insns-single=1200 -fPIC -c ../ncurses/./base/lib_clear.c -o ../obj_s/lib_clear.o
arm-openwrt-linux-gcc -DHAVE_CONFIG_H -DBUILDING_NCURSES -I../ncurses -I. -I../include -DNDEBUG -O2 --param max-inline-insns-single=1200 -fPIC -c ../ncurses/./base/lib_clearok.c -o ../obj_s/lib_clearok.o
guofeng@ubuntu:~/Workspace/gdb_cross_compile/ncurses-6.4$ make install
( cd man && make DESTDIR="" RPATH_LIST="/home/guofeng/Workspace/gdb_cross_compile//lib" install )
make[1]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/ncurses-6.4/man'
mkdir -p /home/guofeng/Workspace/gdb_cross_compile//share/man
/bin/sh ../edit_man.sh normal installing /home/guofeng/Workspace/gdb_cross_compile//share/man . terminfo.5 *-config.1 ./*.[0-9]*
installing /home/guofeng/Workspace/gdb_cross_compile//share/man/man5/terminfo.5.gz
installing /home/guofeng/Workspace/gdb_cross_compile//share/man/man1/ncurses6-config.1.gz
installing /home/guofeng/Workspace/gdb_cross_compile//share/man/man1/captoinfo.1.gz
installing /home/guofeng/Workspace/gdb_cross_compile//share/man/man1/clear.1.gz
installing /home/guofeng/Workspace/gdb_cross_compile//share/man/man3/add_wch.3ncurses.gz
.. installing alias echo_wchar.3ncurses.gz
.. installing alias mvadd_wch.3ncurses.gz
.. installing alias mvwadd_wch.3ncurses.gz
.. installing alias wadd_wch.3ncurses.gz
.. installing alias wecho_wchar.3ncurses.gz
installing /home/guofeng/Workspace/gdb_cross_compile//share/man/man3/add_wchstr.3ncurses.gz
.. installing alias add_wchnstr.3ncurses.gz
.. installing alias mvadd_wchnstr.3ncurses.gz
.. installing alias mvadd_wchstr.3ncurses.gz
.. installing alias mvwadd_wchnstr.3ncurses.gz
.. installing alias mvwadd_wchstr.3ncurses.gz
.. installing alias wadd_wchnstr.3ncurses.gz
.. installing alias wadd_wchstr.3ncurses.gz
installing /home/guofeng/Workspace/gdb_cross_compile//share/man/man3/addch.3ncurses.gz
.. installing alias echochar.3ncurses.gz
.. installing alias mvaddch.3ncurses.gz
.. installing alias mvwaddch.3ncurses.gz
.. installing alias waddch.3ncurses.gz
.. installing alias wechochar.3ncurses.gz
installing /home/guofeng/Workspace/gdb_cross_compile//share/man/man3/addchstr.3ncurses.gz
.. installing alias addchnstr.3ncurses.gz
.. installing alias mvaddchnstr.3ncurses.gz
.. installing alias mvaddchstr.3ncurses.gz
.. installing alias mvwaddchnstr.3ncurses.gz
.. installing alias mvwaddchstr.3ncurses.gz
.. installing alias waddchnstr.3ncurses.gz
.. installing alias waddchstr.3ncurses.gz
installing /home/guofeng/Workspace/gdb_cross_compile//share/man/man3/addstr.3ncurses.gz
guofeng@ubuntu:~/Workspace/gdb_cross_compile$ tree include/
include/
├── ncurses
│ ├── curses.h
│ ├── nc_tparm.h
│ ├── ncurses_dll.h
│ ├── ncurses.h -> curses.h
│ ├── termcap.h
│ ├── term_entry.h
│ ├── term.h
│ ├── tic.h
│ └── unctrl.h
└── termcap.h
1 directory, 10 files
guofeng@ubuntu:~/Workspace/gdb_cross_compile$ tree info/
info/
├── termcap.info
├── termcap.info-1
├── termcap.info-2
├── termcap.info-3
└── termcap.info-4
0 directories, 5 files
guofeng@ubuntu:~/Workspace/gdb_cross_compile$ tree lib/
lib/
├── libncurses.a
├── libncurses_g.a
├── libncurses.so -> libncurses.so.6
├── libncurses.so.6 -> libncurses.so.6.4
├── libncurses.so.6.4
└── libtermcap.a
0 directories, 6 files
guofeng@ubuntu:~/Workspace/gdb_cross_compile$
gmp:
如果没有编译gmp,那么在编译gdb时,会报错。
$ ./configure --prefix=/home/guofeng/Workspace/gdb_cross_compile/ --host=arm-openwrt-linux
$ make
$ make install
$ wget --no-check-certificate "https://gmplib.org/download/gmp/gmp-6.2.1.tar
$ ./configure --prefix=/home/guofeng/Workspace/gdb_cross_compile/ --host=arm-openwrt-linux
checking build system type... nehalem-pc-linux-gnu
checking host system type... arm-openwrt-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-openwrt-linux-strip... arm-openwrt-linux-strip
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking ABI=32
checking compiler arm-openwrt-linux-gcc -O2 -pedantic -fomit-frame-pointer ... yes
checking whether ARM gcc unsigned division works... yes
checking compiler arm-openwrt-linux-gcc -O2 -pedantic -fomit-frame-pointer -march=armv4... yes
checking for arm-openwrt-linux-gcc... arm-openwrt-linux-gcc
...
...
...
config.status: linking mpn/arm/invert_limb.asm to mpn/invert_limb.asm
config.status: linking mpn/arm/aorslsh1_n.asm to mpn/addlsh1_n.asm
config.status: linking mpn/arm/aorslsh1_n.asm to mpn/sublsh1_n.asm
config.status: linking mpn/arm/rsh1aors_n.asm to mpn/rsh1add_n.asm
config.status: linking mpn/arm/rsh1aors_n.asm to mpn/rsh1sub_n.asm
config.status: linking mpn/generic/add_n_sub_n.c to mpn/add_n_sub_n.c
config.status: linking mpn/arm/gmp-mparam.h to gmp-mparam.h
config.status: executing libtool commands
configure: summary of build options:
Version: GNU MP 6.2.1
Host type: arm-openwrt-linux-gnu
ABI: 32
Install prefix: /home/guofeng/Workspace/gdb_cross_compile
Compiler: arm-openwrt-linux-gcc
Static libraries: yes
Shared libraries: yes
guofeng@ubuntu:~/Workspace/gdb_cross_compile/gmp-6.2.1$ make
make all-recursive
make[1]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1'
Making all in tests
make[2]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests'
Making all in .
make[3]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests'
Making all in devel
make[3]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests/devel'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests/devel'
Making all in mpn
make[3]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests/mpn'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests/mpn'
Making all in mpz
make[3]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests/mpz'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests/mpz'
Making all in mpq
make[3]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests/mpq'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests/mpq'
Making all in mpf
make[3]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests/mpf'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests/mpf'
Making all in rand
make[3]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests/rand'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests/rand'
Making all in misc
make[3]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests/misc'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests/misc'
Making all in cxx
make[3]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests/cxx'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests/cxx'
......
sqrtrem.o .libs/libgmp.lax/lt87-sizeinbase.o .libs/libgmp.lax/lt88-get_str.o .libs/libgmp.lax/lt89-set_str.o mpn/compute_powtab.o .libs/libgmp.lax/lt90-scan0.o .libs/libgmp.lax/lt91-scan1.o .libs/libgmp.lax/lt92-popcount.o .libs/libgmp.lax/lt93-hamdist.o .libs/libgmp.lax/lt94-cmp.o mpn/zero_p.o .libs/libgmp.lax/lt95-perfsqr.o .libs/libgmp.lax/lt96-perfpow.o mpn/strongfibo.o mpn/gcd_11.o mpn/gcd_22.o mpn/gcd_1.o .libs/libgmp.lax/lt97-gcd.o mpn/gcdext_1.o .libs/libgmp.lax/lt98-gcdext.o mpn/gcd_subdiv_step.o mpn/gcdext_lehmer.o mpn/div_q.o .libs/libgmp.lax/lt99-tdiv_qr.o mpn/jacbase.o mpn/jacobi_2.o .libs/libgmp.lax/lt100-jacobi.o .libs/libgmp.lax/lt101-get_d.o mpn/matrix22_mul.o mpn/matrix22_mul1_inverse_vector.o mpn/hgcd_matrix.o mpn/hgcd2.o mpn/hgcd_step.o mpn/hgcd_reduce.o mpn/hgcd.o mpn/hgcd_appr.o mpn/hgcd2_jacobi.o mpn/hgcd_jacobi.o mpn/mullo_n.o mpn/mullo_basecase.o mpn/sqrlo.o mpn/sqrlo_basecase.o mpn/toom22_mul.o mpn/toom32_mul.o mpn/toom42_mul.o mpn/toom52_mul.o mpn/toom62_mul.o mpn/toom33_mul.o mpn/toom43_mul.o mpn/toom53_mul.o mpn/toom54_mul.o mpn/toom63_mul.o mpn/toom44_mul.o mpn/toom6h_mul.o mpn/toom6_sqr.o mpn/toom8h_mul.o mpn/toom8_sqr.o mpn/toom_couple_handling.o mpn/toom2_sqr.o mpn/toom3_sqr.o mpn/toom4_sqr.o mpn/toom_eval_dgr3_pm1.o mpn/toom_eval_dgr3_pm2.o mpn/toom_eval_pm1.o mpn/toom_eval_pm2.o mpn/toom_eval_pm2exp.o mpn/toom_eval_pm2rexp.o mpn/toom_interpolate_5pts.o mpn/toom_interpolate_6pts.o mpn/toom_interpolate_7pts.o mpn/toom_interpolate_8pts.o mpn/toom_interpolate_12pts.o mpn/toom_interpolate_16pts.o mpn/invertappr.o .libs/libgmp.lax/lt102-invert.o mpn/binvert.o mpn/mulmod_bnm1.o mpn/sqrmod_bnm1.o mpn/div_qr_1.o mpn/div_qr_1n_pi1.o mpn/div_qr_2.o mpn/div_qr_2n_pi1.o mpn/div_qr_2u_pi1.o mpn/sbpi1_div_q.o mpn/sbpi1_div_qr.o mpn/sbpi1_divappr_q.o mpn/dcpi1_div_q.o mpn/dcpi1_div_qr.o mpn/dcpi1_divappr_q.o mpn/mu_div_qr.o mpn/mu_divappr_q.o mpn/mu_div_q.o mpn/bdiv_q_1.o mpn/sbpi1_bdiv_q.o mpn/sbpi1_bdiv_qr.o mpn/sbpi1_bdiv_r.o mpn/dcpi1_bdiv_q.o mpn/dcpi1_bdiv_qr.o mpn/mu_bdiv_q.o mpn/mu_bdiv_qr.o mpn/bdiv_q.o mpn/bdiv_qr.o mpn/broot.o mpn/brootinv.o mpn/bsqrt.o mpn/bsqrtinv.o .libs/libgmp.lax/lt103-divexact.o mpn/bdiv_dbm1c.o mpn/redc_1.o mpn/redc_2.o mpn/redc_n.o .libs/libgmp.lax/lt104-powm.o mpn/powlo.o mpn/sec_powm.o mpn/sec_mul.o mpn/sec_sqr.o mpn/sec_div_qr.o mpn/sec_div_r.o mpn/sec_pi1_div_qr.o mpn/sec_pi1_div_r.o mpn/sec_add_1.o mpn/sec_sub_1.o mpn/sec_invert.o mpn/trialdiv.o .libs/libgmp.lax/lt105-remove.o mpn/and_n.o mpn/andn_n.o mpn/nand_n.o mpn/ior_n.o mpn/iorn_n.o mpn/nior_n.o mpn/xor_n.o mpn/xnor_n.o mpn/copyi.o mpn/copyd.o mpn/zero.o mpn/sec_tabselect.o mpn/comb_tables.o mpn/udiv.o mpn/invert_limb.o mpn/addlsh1_n.o mpn/sublsh1_n.o mpn/rsh1add_n.o mpn/rsh1sub_n.o mpn/add_n_sub_n.o printf/asprintf.o printf/asprntffuns.o printf/doprnt.o printf/doprntf.o printf/doprnti.o printf/fprintf.o printf/obprintf.o printf/obvprintf.o printf/obprntffuns.o printf/printf.o printf/printffuns.o printf/snprintf.o printf/snprntffuns.o printf/sprintf.o printf/sprintffuns.o printf/vasprintf.o printf/vfprintf.o printf/vprintf.o printf/vsnprintf.o printf/vsprintf.o printf/repl-vsnprintf.o scanf/doscan.o scanf/fscanf.o scanf/fscanffuns.o scanf/scanf.o scanf/sscanf.o scanf/sscanffuns.o scanf/vfscanf.o scanf/vscanf.o scanf/vsscanf.o rand/rand.o rand/randclr.o rand/randdef.o rand/randiset.o rand/randlc2s.o rand/randlc2x.o rand/randmt.o rand/randmts.o rand/rands.o rand/randsd.o rand/randsdui.o rand/randbui.o rand/randmui.o
libtool: link: arm-openwrt-linux-ranlib .libs/libgmp.a
libtool: link: rm -fr .libs/libgmp.lax
libtool: link: ( cd ".libs" && rm -f "libgmp.la" && ln -s "../libgmp.la" "libgmp.la" )
make[2]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1'
make[1]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1'
$ make install
guofeng@ubuntu:~/Workspace/gdb_cross_compile/gmp-6.2.1$ make install
make install-recursive
make[1]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1'
Making install in tests
make[2]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests'
Making install in .
make[3]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests'
make[4]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests'
make[4]: Nothing to be done for 'install-exec-am'.
make[4]: Nothing to be done for 'install-data-am'.
make[4]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests'
make[3]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests'
Making install in devel
make[3]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests/devel'
make[4]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests/devel'
make[4]: Nothing to be done for 'install-exec-am'.
make[4]: Nothing to be done for 'install-data-am'.
make[4]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests/devel'
make[3]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests/devel'
Making install in mpn
make[3]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests/mpn'
make[4]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1/tests/mpn'
...
...
...
----------------------------------------------------------------------
Libraries have been installed in:
/home/guofeng/Workspace/gdb_cross_compile/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the 'LD_RUN_PATH' environment variable
during linking
- use the '-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to '/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
/usr/bin/mkdir -p '/home/guofeng/Workspace/gdb_cross_compile/include'
/usr/bin/install -c -m 644 gmp.h '/home/guofeng/Workspace/gdb_cross_compile/include'
/usr/bin/mkdir -p '/home/guofeng/Workspace/gdb_cross_compile/lib/pkgconfig'
/usr/bin/install -c -m 644 gmp.pc '/home/guofeng/Workspace/gdb_cross_compile/lib/pkgconfig'
make install-data-hook
make[4]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1'
+-------------------------------------------------------------+
| CAUTION: |
| |
| If you have not already run "make check", then we strongly |
| recommend you do so. |
| |
| GMP has been carefully tested by its authors, but compilers |
| are all too often released with serious bugs. GMP tends to |
| explore interesting corners in compilers and has hit bugs |
| on quite a few occasions. |
| |
+-------------------------------------------------------------+
make[4]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1'
make[3]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1'
make[2]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1'
make[1]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gmp-6.2.1'
gdb:
下载源码,可以去官网下载最新release版本,也可以复制下面的gdb的ftp地址。
官网:GDB: The GNU Project Debugger (sourceware.org)https://www.sourceware.org/gdb/
$ wget https://ftp.gnu.org/gnu/gdb/gdb-13.2.tar.xz
$ ./configure --host=arm-openwrt-linux --target=arm-openwrt-linux --prefix=/home/guofeng/Workspace/gdb_cross_compile --enable-static LDFLAGS="-L/home/guofeng/Workspace/gdb_cross_compile/lib" CFLAGS="-I/home/guofeng/Workspace/gdb_crocess_compile/include"
$ make
$ make install
guofeng@ubuntu:~/Workspace/gdb_cross_compile/gdb-13.2$ ./configure --host=arm-openwrt-linux --target=arm-openwrt-linux --prefix=/home/guofeng/Workspace/gdb_cross_compile --enable-static LDFLAGS="-L/home/guofeng/Workspace/gdb_cross_compile/lib" CFLAGS="-I/home/guofeng/Workspace/gdb_crocess_compile/include"
checking build system type... x86_64-pc-linux-gnu
checking host system type... arm-openwrt-linux-gnu
checking target system type... arm-openwrt-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /usr/bin/sed
checking for gawk... no
checking for mawk... mawk
checking for gdbserver support... yes
checking for arm-openwrt-linux-gcc... arm-openwrt-linux-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether arm-openwrt-linux-gcc accepts -g... yes
checking for arm-openwrt-linux-gcc option to accept ISO C89... none needed
guofeng@ubuntu:~/Workspace/gdb_cross_compile/gdb-13.2$ make
make[1]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gdb-13.2'
Configuring in ./libiberty
configure: loading cache ./config.cache
checking whether to enable maintainer-specific portions of Makefiles... no
checking for makeinfo... (cached) /home/guofeng/Workspace/gdb_cross_compile/gdb-13.2/missing makeinfo --split-size=5000000
configure: WARNING:
*** Makeinfo is missing. Info documentation will not be built.
checking for perl... (cached) perl
checking build system type... (cached) x86_64-pc-linux-gnu
checking host system type... (cached) arm-openwrt-linux-gnu
checking for arm-openwrt-linux-ar... (cached) arm-openwrt-linux-ar
checking for arm-openwrt-linux-ranlib... (cached) arm-openwrt-linux-ranlib
checking for -plugin option... checking for arm-openwrt-linux-ar... (cached) arm-openwrt-linux-ar
arm-openwrt-linux-ar: no operation specified
configure: WARNING: Failed: arm-openwrt-linux-ar --plugin /home/guofeng/Workspace/myself/matrix/matrix/toolchains/r328-toolchain/toolchain-sunxi-musl/toolchain/bin/../libexec/gcc/arm-openwrt-linux-muslgnueabi/6.4.1/liblto_plugin.so rc
no
checking whether to install libiberty headers and static library... no
configure: target_header_dir =
checking for arm-openwrt-linux-gcc... (cached) arm-openwrt-linux-gcc
......
......
touch stamp-guile
rm -rf ./system-gdbinit
mkdir ./system-gdbinit
files='elinos.py wrs-linux.py' ; \
for file in $files ; do \
f=./../system-gdbinit/$file ; \
if test -f $f ; then \
/usr/bin/install -c -m 644 $f ./system-gdbinit ; \
fi ; \
done
touch stamp-system-gdbinit
make[4]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gdb-13.2/gdb/data-directory'
make[3]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gdb-13.2/gdb'
make[2]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gdb-13.2/gdb'
make[1]: Nothing to be done for 'all-target'.
make[1]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gdb-13.2
guofeng@ubuntu:~/Workspace/gdb_cross_compile/gdb-13.2$ make install
make[1]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gdb-13.2'
/bin/bash ./mkinstalldirs /home/guofeng/Workspace/gdb_cross_compile /home/guofeng/Workspace/gdb_cross_compile
make[2]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gdb-13.2/libsframe'
make[3]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gdb-13.2/libsframe'
/usr/bin/mkdir -p '/home/guofeng/Workspace/gdb_cross_compile/share/info'
/usr/bin/install -c -m 644 ./doc/sframe-spec.info '/home/guofeng/Workspace/gdb_cross_compile/share/info'
install-info --info-dir='/home/guofeng/Workspace/gdb_cross_compile/share/info' '/home/guofeng/Workspace/gdb_cross_compile/share/info/sframe-spec.info'
make[3]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gdb-13.2/libsframe'
make[2]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gdb-13.2/libsframe'
make[2]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gdb-13.2/bfd'
make install-recursive
make[3]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gdb-13.2/bfd'
Making install in po
make[4]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gdb-13.2/bfd/po'
if test -r .././../mkinstalldirs; then \
.././../mkinstalldirs /home/guofeng/Workspace/gdb_cross_compile/share; \
else \
../mkinstalldirs /home/guofeng/Workspace/gdb_cross_compile/share; \
fi
mkdir -p -- /home/guofeng/Workspace/gdb_cross_compile/share/locale/da/LC_MESSAGES
installing da.gmo as /home/guofeng/Workspace/gdb_cross_compile/share/locale/da/LC_MESSAGES/bfd.mo
mkdir -p -- /home/guofeng/Workspace/gdb_cross_compile/share/locale/es/LC_MESSAGES
installing es.gmo as /home/guofeng/Workspace/gdb_cross_compile/share/locale/es/LC_MESSAGES/bfd.mo
mkdir -p -- /home/guofeng/Workspace/gdb_cross_compile/share/locale/fi/LC_MESSAGES
installing fi.gmo as /home/guofeng/Workspace/gdb_cross_compile/share/locale/fi/LC_MESSAGES/bfd.mo
mkdir -p -- /home/guofeng/Workspace/gdb_cross_compile/share/locale/fr/LC_MESSAGES
installing fr.gmo as /home/guofeng/Workspace/gdb_cross_compile/share/locale/fr/LC_MESSAGES/bfd.mo
mkdir -p -- /home/guofeng/Workspace/gdb_cross_compile/share/locale/hr/LC_MESSAGES
installing hr.gmo as /home/guofeng/Workspace/gdb_cross_compile/share/locale/hr/LC_MESSAGES/bfd.mo
mkdir -p -- /home/guofeng/Workspace/gdb_cross_compile/share/locale/id/LC_MESSAGES
installing id.gmo as /home/guofeng/Workspace/gdb_cross_compile/share/locale/id/LC_MESSAGES/bfd.mo
mkdir -p -- /home/guofeng/Workspace/gdb_cross_compile/share/locale/ja/LC_MESSAGES
installing ja.gmo as /home/guofeng/Workspace/gdb_cross_compile/share/locale/ja/LC_MESSAGES/bfd.mo
mkdir -p -- /home/guofeng/Workspace/gdb_cross_compile/share/locale/pt/LC_MESSAGES
......
......
......
......
......
......
......
make[6]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gdb-13.2/gdb/data-directory'
make[5]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gdb-13.2/gdb/data-directory'
make[4]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gdb-13.2/gdb'
make[3]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gdb-13.2/gdb'
make[2]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gdb-13.2/gdb'
make[2]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gdb-13.2/libctf'
make[3]: Entering directory '/home/guofeng/Workspace/gdb_cross_compile/gdb-13.2/libctf'
/usr/bin/mkdir -p '/home/guofeng/Workspace/gdb_cross_compile/lib'
/bin/bash ./libtool --mode=install /usr/bin/install -c libctf.la libctf-nobfd.la '/home/guofeng/Workspace/gdb_cross_compile/lib'
libtool: install: /usr/bin/install -c .libs/libctf.lai /home/guofeng/Workspace/gdb_cross_compile/lib/libctf.la
libtool: install: /usr/bin/install -c .libs/libctf-nobfd.lai /home/guofeng/Workspace/gdb_cross_compile/lib/libctf-nobfd.la
libtool: install: /usr/bin/install -c .libs/libctf.a /home/guofeng/Workspace/gdb_cross_compile/lib/libctf.a
libtool: install: chmod 644 /home/guofeng/Workspace/gdb_cross_compile/lib/libctf.a
libtool: install: arm-openwrt-linux-ranlib --plugin /home/guofeng/Workspace/myself/matrix/matrix/toolchains/r328-toolchain/toolchain-sunxi-musl/toolchain/bin/../libexec/gcc/arm-openwrt-linux-muslgnueabi/6.4.1/liblto_plugin.so /home/guofeng/Workspace/gdb_cross_compile/lib/libctf.a
libtool: install: /usr/bin/install -c .libs/libctf-nobfd.a /home/guofeng/Workspace/gdb_cross_compile/lib/libctf-nobfd.a
libtool: install: chmod 644 /home/guofeng/Workspace/gdb_cross_compile/lib/libctf-nobfd.a
libtool: install: arm-openwrt-linux-ranlib --plugin /home/guofeng/Workspace/myself/matrix/matrix/toolchains/r328-toolchain/toolchain-sunxi-musl/toolchain/bin/../libexec/gcc/arm-openwrt-linux-muslgnueabi/6.4.1/liblto_plugin.so /home/guofeng/Workspace/gdb_cross_compile/lib/libctf-nobfd.a
libtool: finish: PATH="/home/guofeng/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/guofeng/.local/bin:/home/guofeng/Workspace/myself/matrix/matrix/toolchains/r328-toolchain/toolchain-sunxi-musl/toolchain/bin:/sbin" ldconfig -n /home/guofeng/Workspace/gdb_cross_compile/lib
----------------------------------------------------------------------
Libraries have been installed in:
/home/guofeng/Workspace/gdb_cross_compile/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
/usr/bin/mkdir -p '/home/guofeng/Workspace/gdb_cross_compile/include'
/usr/bin/install -c -m 644 ./../include/ctf.h ./../include/ctf-api.h '/home/guofeng/Workspace/gdb_cross_compile/include'
/usr/bin/mkdir -p '/home/guofeng/Workspace/gdb_cross_compile/share/info'
/usr/bin/install -c -m 644 ./doc/ctf-spec.info '/home/guofeng/Workspace/gdb_cross_compile/share/info'
install-info --info-dir='/home/guofeng/Workspace/gdb_cross_compile/share/info' '/home/guofeng/Workspace/gdb_cross_compile/share/info/ctf-spec.info'
make[3]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gdb-13.2/libctf'
make[2]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gdb-13.2/libctf'
make[1]: Nothing to be done for 'install-target'.
make[1]: Leaving directory '/home/guofeng/Workspace/gdb_cross_compile/gdb-13.2'
编译产物:
编译的产物,在gdb_cross_compile文件夹的bin目录中,在该目录中可以找到gcore,gdb,gdbserver等工具,需要主要的是,gdb文件是依赖so的(依赖libgmp.so和libncurses.so),实际使用时需要将这两个so复制到目标板上,同时配置export LD_LIBRARY_PATH=so文件存放路径。
然后就可以在目标板上运行gdb了。