问题一
在运行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