在centos8中,我像这样编译了c文件,但错了:
# LANG=C gcc -static pointer.c -o pointer
/usr/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status如果删除"-static",就可以了。
在Ubuntu-20.04中,带和不带"-statis“都可以。我在Ubuntu找到了libc.a:
/usr/lib/x86_64-linux-gnu/libc.a"libc.a“由Ubuntu-20.04命令安装:
apt install libc6-dev在centos8中,如何使用“”安装libc.a文件?
我试过:
# dnf install glibc-static
Last metadata expiration check: 1:36:14 ago on Thu Aug 26 16:13:42 2021.
No match for argument: glibc-static
Error: Unable to find a match: glibc-static
# dnf config-manager --enable
# dnf install glibc-static
Last metadata expiration check: 1:36:26 ago on Thu Aug 26 16:13:42 2021.
No match for argument: glibc-static
Error: Unable to find a match: glibc-static编辑:
通过下列方式解决:
# dnf --enablerepo=powertools install glibc-static参考链接:
发布于 2021-08-26 09:40:16
很可能您缺少静态glibc库,默认情况下没有安装这些库。在CentOS中,用
dnf install glibc-static这应该能行。
dnf info glibc-static摘录
描述:glibc静态包包含用于-static链接的C库静态库。你不需要这些,除非你静态链接,这是非常气馁的。
注意:如果您没有看到包,您可能需要添加"PowerTools“回购:
dnf config-manager --enable PowerTools另见https://centos.pkgs.org/8/centos-powertools-x86_64/glibc-static-2.28-151.el8.x86_64.rpm.html。
https://stackoverflow.com/questions/68936024
复制相似问题