gpt4 book ai didi

c - 如何在centos8中使用 "dnf install "安装文件libc.a

转载 作者:行者123 更新时间:2023-12-03 08:17:19 25 4
gpt4 key购买 nike

在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”和不带“-statis”都可以。我在Ubuntu中找到了libc.a:

/usr/lib/x86_64-linux-gnu/libc.a

“libc.a”在 Ubuntu-20.04 中通过命令安装:

apt install libc6-dev

在centos8中,如何使用“dnf install”安装文件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

引用链接:

https://centos.pkgs.org/8/centos-powertools-x86_64/glibc-static-2.28-151.el8.x86_64.rpm.html

最佳答案

很可能您缺少静态 glibc 库,默认情况下不会安装这些库。在 CentOS 中,使用以下命令安装它们

dnf install glibc-static

这应该有效。

摘自dnf info glibc-static:

Description : The glibc-static package contains the C library static librariesfor -static linking. You don't need these, unless you link statically,which is highly discouraged.


注意:如果您没有看到该软件包,您可能需要添加“PowerTools”存储库:

dnf config-manager --enable PowerTools

另请参阅 this link .

关于c - 如何在centos8中使用 "dnf install "安装文件libc.a,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68936024/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com