ld加上-static -lc参数报错`ld: cannot find -lc`处理方法
·
cat /etc/redhat-release看到操作系统是CentOS Linux release 7.6.1810,uname -r看到内核版本是3.10.0-957.el7.x86_64,as --version看到as的版本是2.27-34.base.el7,ld --version看到ld的版本是2.27-34.base.el7。

absCallWithStart.s里边的代码如下:
.section .data
.global _start
.section .text
_start:
movq $-5,%rdi
call abs
movq %rax,%rdi
movq $0x3c,%rax
syscall
这一段代码主要是求-5的绝对值。
as absCallWithStart.s -o absCallWithStart.o进行汇编。
ld absCallWithStart.o -static -lc -o absCallWithStart进行链接,报错ld: cannot find -lc。

sudo yum install -y glibc-static安装glibc-static。

ld absCallWithStart.o -static -lc -o absCallWithStart再次进行链接,./absCallWithStart进行执行,echo $?查看一下返回值。

更多推荐
所有评论(0)