You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CentOS8系统如何通过dnf命令安装静态库文件libc.a

CentOS 8 静态编译C文件报错解决方案

问题描述

在CentOS 8中执行静态编译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环境:
Ubuntu 20.04系统中无论是否添加-static参数都可以正常编译,系统内libc.a的路径为/usr/lib/x86_64-linux-gnu/libc.a,可通过命令apt install libc6-dev安装该静态库文件。

问题诉求

在CentOS 8系统中,如何使用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

最终解决方案

执行以下命令即可成功安装glibc-static包,获得libc.a文件:

# dnf --enablerepo=powertools install glibc-static

内容的提问来源于stack exchange,提问作者acodebang

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 08:12:02