Can not build libdwarf

I download the most updated libdwarf version in archive file. Extract the files and run the following command

cd dwarf-2013-02-07/libdwarf
./configure --enable-shared
make

I got the following compile error. I don't know why. I tried many other version and got the same error.

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

1 Answer

You are missing a dependency, try adding the following:

sudo apt-get install libelf-dev

And then all will be well. I have tested this under Trusty Tahr...

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like