Linux源码编译问题总结

问题一

在运行asapp书中第7章链接例子时,在使用gcc -static -o prog main.o ./libvector.a 命令进行链接时出现以下错误:

/usr/bin/ld: 找不到 -lc
collect2: 错误:ld 返回 1

原因
在新版本的linux 系统下安装 glibc-devel、glibc和gcc-c++时,都不会安装libc.a. 只安装libc.so. 所以当使用-static时,libc.a不能使用。只能报找不到libc了。

解决方法
安装glibc-static
sudo yum install glibc-static

问题二

[root@localhost rsync-3.2.7]# make CFLAGS="-static" EXEEXT="-static"
gcc -std=gnu11 -I. -I. -static  -c flist.c -o flist.o
gcc -std=gnu11 -I. -I. -static  -c rsync.c -o rsync.o
gcc -std=gnu11 -I. -I. -static  -c generator.c -o generator.o
gcc -std=gnu11 -I. -I. -static  -c receiver.c -o receiver.o
gcc -std=gnu11 -I. -I. -static  -c cleanup.c -o cleanup.o
gcc -std=gnu11 -I. -I. -static  -c sender.c -o sender.o
gcc -std=gnu11 -I. -I. -static  -c exclude.c -o exclude.o
gcc -std=gnu11 -I. -I. -static  -c util1.c -o util1.o
gcc -std=gnu11 -I. -I. -static  -c util2.c -o util2.o
gcc -std=gnu11 -I. -I. -static  -c main.c -o main.o
main.c:30:18: 致命错误:popt.h:没有那个文件或目录
 #include <popt.h>
                  ^
编译中断。
make: *** [main.o] 错误 1

解决方式

sudo yum install popt-devel

问题三: no acceptable C compiler found in $PATH,没有合适的编译器

root@wps:/home/wps/tar-1.35# ./configure  LDFLAGS=-static
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... no
checking whether make supports nested variables... no
checking whether UID '0' is supported by ustar format... yes
checking whether GID '0' is supported by ustar format... yes
checking how to create a ustar tar archive... gnutar
checking whether make supports nested variables... (cached) no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
checking for clang... no
configure: error: in `/home/wps/tar-1.35':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more detail

解决方案:

sudo apt-get update
sudo apt-get install build-essential

问题四:提示you should not run configure as root

you should not run configure as root (set FORCE_UNSAFE_CONFIGURE=1 in environment to bypass this check)


解决方法:

export FORCE_UNSAFE_CONFIGURE=1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

运维之美@

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值