https://www.cnblogs.com/Dennis-mi/articles/5018745.html
https://blog.csdn.net/zhaoxd200808501/article/details/77838933
tar.xz:tar xvJf ./gdb-7.8.tar.xz
tar.gz:tar -zxvf ./gdb-7.8.tar.gz
./configure --host=arm-mol-linux-uclibcgnueabihf --target=arm-mol-linux-uclibcgnueabihf --program-prefix=arm-mol-linux-uclibcgnueabihf- --prefix=$PWD/__install
–host:表示主机使用的编译工具链,一般是arm-linux
,也可以是芯片平台的编译工具链。
–target:表示芯片平台的编译工具链,如arm-mol-linux-uclibcgnueabihf
。
–program-prefix:表示目标生成的前缀名字。
–prefix:表示make install输出的目录。
make -j29
make install
,输出到前指定的目录中./__install/bin
目录下Q1:undefined reference to `exp’
A1:修改makefile、增加-lm编译指令
Q1:‘log2’ is not a member of ‘std’
dwarf2/index-write.c: In member function 'void debug_names::build()':
dwarf2/index-write.c:780:32: error: 'log2' is not a member of 'std'
(std::pow (2, std::ceil (std::log2 (name_count * 4 / 3))));
^
dwarf2/index-write.c:780:32: note: suggested alternative:
In file included from /opt/molchip/arm-molchip-linux/arm-mol-linux-uclibcgnueabihf/sysroot/usr/include/features.h:416:0,
from /opt/molchip/arm-molchip-linux/arm-mol-linux-uclibcgnueabihf/sysroot/usr/include/stdio.h:28,
from ./../gnulib/import/stdio.h:43,
from ./../gdbsupport/common-defs.h:86,
from ./defs.h:28,
from dwarf2/index-write.c:20:
/opt/molchip/arm-molchip-linux/arm-mol-linux-uclibcgnueabihf/sysroot/usr/include/bits/mathcalls.h:158:1: note: 'log2'
__MATHCALL (log2,, (_Mdouble_ __x))
^
CXX frame-base.o
CXX frame-unwind.o
CXX frame.o
CXX gcore.o
CXX gdb-demangle.o
CXX gdb_bfd.o
CXX gdb_obstack.o
CXX gdb_regex.o
make[2]: *** [dwarf2/index-write.o] 错误 1
make[2]: *** 正在等待未完成的任务....
make[2]:正在离开目录 `/data1/hongmiao/work/Code/MyCode/gdb-10.2/gdb'
make[1]: *** [all-gdb] 错误 2
make[1]:正在离开目录 `/data1/hongmiao/work/Code/MyCode/gdb-10.2'
make: *** [all] 错误 2
A1:使用log函数替换log2方法
将./gdb/dwarf2/index-write.c出错的行
m_bucket_table.resize
(std::pow (2, std::ceil (std::log2 (name_count * 4 / 3))));
使用log函数替换log2方法
m_bucket_table.resize
(std::pow (2, std::ceil (std::log(name_count * 4 / 3) / std::log((float)2.0))));
Q2:undefined reference to ‘_obstack_free’
/opt/molchip/arm-molchip-linux/bin/../lib/gcc/arm-mol-linux-uclibcgnueabihf/4.9.4/../../../../arm-mol-linux-uclibcgnueabihf/bin/ld.bfd: ada-exp.o: in function `ada_parse(parser_state*)':
/data1/hongmiao/work/Code/MyCode/gdb-10.2/gdb/ada-exp.y:738: undefined reference to `_obstack_free'
/opt/molchip/arm-molchip-linux/bin/../lib/gcc/arm-mol-linux-uclibcgnueabihf/4.9.4/../../../../arm-mol-linux-uclibcgnueabihf/bin/ld.bfd: ada-lang.o: in function `ada_clear_symbol_cache()':
/data1/hongmiao/work/Code/MyCode/gdb-10.2/gdb/ada-lang.c:4568: undefined reference to `_obstack_free'
/opt/molchip/arm-molchip-linux/bin/../lib/gcc/arm-mol-linux-uclibcgnueabihf/4.9.4/../../../../arm-mol-linux-uclibcgnueabihf/bin/ld.bfd: ada-lang.o: in function `~auto_obstack':
/data1/hongmiao/work/Code/MyCode/gdb-10.2/gdb/gdb_obstack.h:126: undefined reference to `_obstack_free'
/opt/molchip/arm-molchip-linux/bin/../lib/gcc/arm-mol-linux-uclibcgnueabihf/4.9.4/../../../../arm-mol-linux-uclibcgnueabihf/bin/ld.bfd: /data1/hongmiao/work/Code/MyCode/gdb-10.2/gdb/gdb_obstack.h:126: undefined reference to `_obstack_free'
/opt/molchip/arm-molchip-linux/bin/../lib/gcc/arm-mol-linux-uclibcgnueabihf/4.9.4/../../../../arm-mol-linux-uclibcgnueabihf/bin/ld.bfd: ada-lang.o: in function `ada_free_symbol_cache':
/data1/hongmiao/work/Code/MyCode/gdb-10.2/gdb/ada-lang.c:4539: undefined reference to `_obstack_free'
/opt/molchip/arm-molchip-linux/bin/../lib/gcc/arm-mol-linux-uclibcgnueabihf/4.9.4/../../../../arm-mol-linux-uclibcgnueabihf/bin/ld.bfd: c-exp.o:/data1/hongmiao/work/Code/MyCode/gdb-10.2/gdb/c-exp.y:2351: more undefined references to `_obstack_free' follow
collect2: error: ld returned 1 exit status
make[2]: *** [gdb] 错误 1
make[2]:正在离开目录 `/data1/hongmiao/work/Code/MyCode/gdb-10.2/gdb'
make[1]: *** [all-gdb] 错误 2
make[1]:正在离开目录 `/data1/hongmiao/work/Code/MyCode/gdb-10.2'
make: *** [all] 错误 2
A2:使用宏定义使用_obstack_free函数替换obstack_free
在./include/obstack.h中增加定义
#ifndef obstack_free
#define _obstack_free obstack_free
#endif
Q3:configure: error: no termcap library found
A3:https://www.codenong.com/cs109695462/