/usr/bin/ld: /usr/local/lib/libz.a(crc32.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libz.a: could not read symbols: Bad value
一般是64 位 电脑才会出现。
解决方法如下:
cd zlib-1.2.3 //进入zlib目录
CFLAGS="-O3 -fPIC" ./configure //使用64位元的方法进行编译makemake installmake clean上面操作演示结果如下:
[root@unix-server1 zlib-1.2.3]# CFLAGS="-O3 -fPIC" ./configure --prefix=/usr/local/zlib/
Checking for gcc...Building static library libz.a version 1.2.3 with gcc.Checking for unistd.h... Yes.Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()Checking for vsnprintf() in stdio.h... Yes.Checking for return value of vsnprintf()... Yes.Checking for errno.h... Yes.Checking for mmap support... Yes.[root@unix-server1 zlib-1.2.3]# makegcc -O3 -fPIC -DUSE_MMAP -c -o example.o example.cgcc -O3 -fPIC -DUSE_MMAP -c -o adler32.o adler32.cgcc -O3 -fPIC -DUSE_MMAP -c -o compress.o compress.cgcc -O3 -fPIC -DUSE_MMAP -c -o crc32.o crc32.cgcc -O3 -fPIC -DUSE_MMAP -c -o gzio.o gzio.cgcc -O3 -fPIC -DUSE_MMAP -c -o uncompr.o uncompr.cgcc -O3 -fPIC -DUSE_MMAP -c -o deflate.o deflate.cgcc -O3 -fPIC -DUSE_MMAP -c -o trees.o trees.cgcc -O3 -fPIC -DUSE_MMAP -c -o zutil.o zutil.cgcc -O3 -fPIC -DUSE_MMAP -c -o inflate.o inflate.cgcc -O3 -fPIC -DUSE_MMAP -c -o infback.o infback.cgcc -O3 -fPIC -DUSE_MMAP -c -o inftrees.o inftrees.cgcc -O3 -fPIC -DUSE_MMAP -c -o inffast.o inffast.car rc libz.a adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.ogcc -O3 -fPIC -DUSE_MMAP -o example example.o -L. libz.agcc -O3 -fPIC -DUSE_MMAP -c -o minigzip.o minigzip.cgcc -O3 -fPIC -DUSE_MMAP -o minigzip minigzip.o -L. libz.a[root@unix-server1 zlib-1.2.3]# make installcp zlib.h zconf.h /usr/local/zlib//includechmod 644 /usr/local/zlib//include/zlib.h /usr/local/zlib//include/zconf.hcp libz.a /usr/local/zlib//libcd /usr/local/zlib//lib; chmod 755 libz.acd /usr/local/zlib//lib; if test -f libz.so.1.2.3; then \ rm -f libz.so libz.so.1; \ ln -s libz.so.1.2.3 libz.so; \ ln -s libz.so.1.2.3 libz.so.1; \ (ldconfig || true) >/dev/null 2>&1; \ ficp zlib.3 /usr/local/zlib//share/man/man3chmod 644 /usr/local/zlib//share/man/man3/zlib.3[root@unix-server1 zlib-1.2.3]# make cleanrm -f *.o *~ example minigzip \ libz.* foo.gz so_locations \ _match.s maketree contrib/infback9/*.o[root@unix-server1 zlib-1.2.3]#