首页 > 解决方案 > 错误 gcc - 未定义对符号 '__getauxval@@GLIBC_2.17' 的引用

问题描述

大家好。

我正在尝试编译简单的 C 代码。

#include <stdio.h>
void main()
{
printf("Hello world\n");
}

但我得到这个错误。

$ gcc main.c
/data/data/com.termux/files/usr/bin/ld: /data/data/com.termux/files/usr/bin/../lib/gcc/aarch64-unknown-linux-gnu/10.2.0/libgcc.a(lse-init.o): undefined reference to symbol '__getauxval@@GLIBC_2.17'
/data/data/com.termux/files/usr/bin/ld: /data/data/com.termux/files/usr/lib/libc.so.6: error adding symbols: DSO missing from command line                                       
collect2: error: ld returned 1 exit status

我了解该错误是由于 compidator 找不到字体而发生的,但这并不准确。同样的错误发生在C++中。

如何修复此错误?

标签: cgcc

解决方案


简而言之,发生此错误是因为 libc 类型的库不在公共目录中。这些库:

-rwxr-xr-x 1 10504 10504 1827624 Aug  4 16:27 /lib/conlib/libc-2.32.so
-rw-r--r-- 1 10504 10504 4592750 Aug  4 16:27 /lib/conlib/libc.a
-rw-r--r-- 1 10504 10504     351 Aug  4 16:27 /lib/conlib/libc.so
lrwxrwxrwx 1 10504 10504      18 Aug  4 16:27 /lib/conlib/libc.so.6 -> libc-2.32.so
-rw-r--r-- 1 10504 10504   24964 Aug  4 16:27 /lib/conlib/libc_nonshared.a

推荐阅读