angelpan1014

 

/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/bin/ld:

场景:/usr/lib64/gcc/x86_64-suse-linux/4.1.2/http://www.cnblogs.com/http://www.cnblogs.com/x86_64-suse-linux/bin/ld: hello.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
hello.o: could not read symbols: Bad value

别人的错误: 

/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位元的方法进行编译

make

make install

make 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]# make
gcc -O3 -fPIC -DUSE_MMAP   -c -o example.o example.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o adler32.o adler32.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o compress.o compress.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o crc32.o crc32.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o gzio.o gzio.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o uncompr.o uncompr.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o deflate.o deflate.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o trees.o trees.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o zutil.o zutil.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o inflate.o inflate.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o infback.o infback.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o inftrees.o inftrees.c
gcc -O3 -fPIC -DUSE_MMAP   -c -o inffast.o inffast.c
ar 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.o
gcc -O3 -fPIC -DUSE_MMAP -o example example.o -L. libz.a
gcc -O3 -fPIC -DUSE_MMAP   -c -o minigzip.o minigzip.c
gcc -O3 -fPIC -DUSE_MMAP -o minigzip minigzip.o -L. libz.a
[root@unix-server1 zlib-1.2.3]# make install
cp zlib.h zconf.h /usr/local/zlib//include
chmod 644 /usr/local/zlib//include/zlib.h /usr/local/zlib//include/zconf.h
cp libz.a /usr/local/zlib//lib
cd /usr/local/zlib//lib; chmod 755 libz.a
cd /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; \
        fi
cp zlib.3 /usr/local/zlib//share/man/man3
chmod 644 /usr/local/zlib//share/man/man3/zlib.3
[root@unix-server1 zlib-1.2.3]# make clean
rm -f *.o *~ example minigzip \
           libz.* foo.gz so_locations \
           _match.s maketree contrib/infback9/*.o
[root@unix-server1 zlib-1.2.3]#

posted on 2012-10-25 14:22  angelpan1014  阅读(7487)  评论(0编辑  收藏  举报

导航