我下载了elfutils 0.170和0.169,但由于隐式函数声明,无法使用gcc编译它们中的任何一个。我在elfutils makefile中找不到指定-Werror或-Werror = implicit-function-declaration的任何位置。有解决此编译错误的主意吗?

https://sourceware.org/elfutils/ftp/0.170/
我的脚步

1:bzip2 -d elfutils-0.170.tar.bz2
2:tar -xvf elfutils-0.170.tar
3:./配置
4:制作

然后出现下面的错误。
elf_compress_gnu.c:在函数“elf_compress_gnu”中:
elf_compress_gnu.c:114:28:错误:函数'htobe64'的隐式声明[-Werror = implicit-function-declaration]
uint64_t be64_size = htobe64(orig_size);
^
elf_compress_gnu.c:163:15:错误:函数'be64toh'的隐式声明[-Werror = implicit-function-declaration]
gsize = be64toh(gsize);
^
cc1:将所有警告视为错误

最佳答案

elfutils错误地使用了htobe64,它不是任何标准,仅在glibc和BSD的子集中可用。

由于您使用的是GCC,因此可以使用Ulf Hermann的补丁来解决此问题:

  • Add replacement endian.h and byteswap.h to libgnu

  • 它基于GCC内置函数添加了htobe64的实现,因此,当GCC用作编译器时,它就可用,而与C库提供的功能无关。

    09-29 23:24