我在存档文件中下载了最新的 libdwarf 版本。提取文件并运行以下命令
cd dwarf-2013-02-07/libdwarf
./configure --enable-shared
make
我得到了以下编译错误。我不知道为什么。我尝试了许多其他版本,但得到了同样的错误。
cd libdwarf && make
make[1]: Entering directory `/home/lihao/Downloads/dwarf-20151114/libdwarf'
echo "do nothing " none
do nothing none
gcc -g -O2 -I. -I. -c -o dwarf_elf_access.o dwarf_elf_access.c
dwarf_elf_access.c: In function ‘dwarf_elf_object_access_internals_init’:
dwarf_elf_access.c:238:21: warning: assignment makes pointer from integer without a cast [enabled by default]
if ((ehdr_ident = elf_getident(elf, NULL)) == NULL) {
^
dwarf_elf_access.c:267:21: warning: assignment makes pointer from integer without a cast [enabled by default]
obj->ehdr32 = elf32_getehdr(elf);
^
dwarf_elf_access.c: In function ‘dwarf_elf_object_access_get_section_info’:
dwarf_elf_access.c:349:5: error: unknown type name ‘Elf_Scn’
Elf_Scn *scn = 0;
^
dwarf_elf_access.c:352:9: warning: assignment makes pointer from integer without a cast [enabled by default]
scn = elf_getscn(obj->elf, section_index);
^
dwarf_elf_access.c:385:17: warning: assignment makes pointer from integer without a cast [enabled by default]
if ((shdr32 = elf32_getshdr(scn)) == NULL) {
^
dwarf_elf_access.c:398:19: warning: assignment makes pointer from integer without a cast [enabled by default]
ret_scn->name = elf_strptr(obj->elf, obj->ehdr32->e_shstrndx,
^
dwarf_elf_access.c: In function ‘dwarf_elf_object_access_load_section’:
dwarf_elf_access.c:1215:9: error: unknown type name ‘Elf_Scn’
Elf_Scn *scn = 0;
^
dwarf_elf_access.c:1216:9: error: unknown type name ‘Elf_Data’
Elf_Data *data = 0;
^
dwarf_elf_access.c:1218:13: warning: assignment makes pointer from integer without a cast [enabled by default]
scn = elf_getscn(obj->elf, section_index);
^
dwarf_elf_access.c:1230:14: warning: assignment makes pointer from integer without a cast [enabled by default]
data = elf_getdata(scn, NULL);
^
dwarf_elf_access.c:1235:29: error: request for member ‘d_buf’ in something not a structure or union
*section_data = data->d_buf;
^
make[1]: *** [dwarf_elf_access.o] Error 1
make[1]: Leaving directory `/home/lihao/Downloads/dwarf-20151114/libdwarf'
make: *** [basic] Error 2
答案1
您缺少依赖项,请尝试添加以下内容:
sudo apt-get install libelf-dev
然后一切都会好起来的。我已经在 Trusty Tahr 下测试过了...