elfutils 编译错误隐式函数声明

elfutils compilation error implicit-function-declaration

本文关键字:函数 声明 编译 错误 elfutils      更新时间:2023-10-16

我下载了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.bz22:焦油-xvf 精灵-0.170.tar3: ./配置
4:制作

然后出现以下错误。elf_compress_gnu.c:在函数"elf_compress_gnu"中:elf_compress_gnu.c:114:28:错误:函数'htobe64'的隐式声明[-Werror=隐式函数声明] uint64_t be64_size = htobe64 (orig_size(; ^elf_compress_gnu.c:163:15:错误:函数"be64toh"的隐式声明 [-Werror=隐式函数声明] gsize = be64toh (gsize(; ^CC1:所有警告都被视为错误

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

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

  • 将替换 endian.h 和 byteswap.h 添加到 libgnu

它添加了基于 GCC 内置函数的htobe64实现,因此当 GCC 用作编译器时,它可用,独立于 C 库提供的内容。