glibc configure 无法识别 Linux 头文件

glibc configure doesn't recognize Linux header files

我已经从 kernel.org 下载了 Linux 内核源代码以将 glibc 交叉编译到 aarch64 Linux(由 QEMU 模拟)。但是,当我 运行:

[teo.samarzija@teos-acer-laptop glibc-2.31-build]$ ../glibc-2.31/configure --with-headers=/home/teo.samarzija/linux-5.7.6/include --with-binutils=/home/teo.samarzija/arm-gcc/bin --prefix=/home/teo.samarzija/arm-gcc --build=x86_64-pc-linux --host=aarch64-none-linux-gnu CC=aarch64-none-linux-gnu-gcc

我收到这个错误:

checking installed Linux kernel header files... missing or too old!
configure: error: GNU libc requires kernel header files from
Linux 3.2.0 or later to be installed before configuring.
The kernel header files are found usually in /usr/include/asm and
/usr/include/linux; make sure these directories use files from
Linux 3.2.0 or later.  This check uses <linux/version.h>, so
make sure that file was built correctly when installing the kernel header
files.  To use kernel headers not from /usr/include/linux, use the
configure option --with-headers.

知道我做错了什么吗?

您可以通过为 Linux 安装自动工具包或类似工具来使用主机配置二进制文件。尝试使用 CFLAGS="-I /home/teo.samarzija/linux-5.7.6/include"

--with-headers=/home/teo.samarzija/linux-5.7.6/include

这看起来像是签出的内核树。您需要先安装内核树并指定该位置,使用如下命令:

make -C /home/teo.samarzija/linux-5.7.6 ARCH=arm64 \
  INSTALL_HDR_PATH=/home/teo.samarzija/linux-5.7.6-installed/usr \
  headers_install

(你还需要设置CC等合适的交叉编译器。)

并使用--with-headers=/home/teo.samarzija/linux-5.7.6-installed/usr/include.