当前位置: 技术问答>linux和unix
Linux 64位安装libpng编译安装问题
来源: 互联网 发布时间:2017-05-24
本文导语: 执行make错误信息,在安装目录下没有创建libpng [root@localhost libpng-1.2.31]# make make all-am make[1]: Entering directory `/lamp/libpng-1.2.31' /bin/sh ./libtool --tag=CC --mode=link gcc -g -O2 -no-undefined -export-dynamic -version-number 0:3...
执行make错误信息,在安装目录下没有创建libpng
[root@localhost libpng-1.2.31]# make
make all-am
make[1]: Entering directory `/lamp/libpng-1.2.31'
/bin/sh ./libtool --tag=CC --mode=link gcc -g -O2 -no-undefined -export-dynamic -version-number 0:31:0 -Wl,--version-script=libpng.vers -o libpng12.la -rpath /usr/local/libpng/lib libpng12_la-png.lo libpng12_la-pngset.lo libpng12_la-pngget.lo libpng12_la-pngrutil.lo libpng12_la-pngtrans.lo libpng12_la-pngwutil.lo libpng12_la-pngread.lo libpng12_la-pngrio.lo libpng12_la-pngwio.lo libpng12_la-pngwrite.lo libpng12_la-pngrtran.lo libpng12_la-pngwtran.lo libpng12_la-pngmem.lo libpng12_la-pngerror.lo libpng12_la-pngpread.lo -lz -lm
libtool: link: gcc -shared .libs/libpng12_la-png.o .libs/libpng12_la-pngset.o .libs/libpng12_la-pngget.o .libs/libpng12_la-pngrutil.o .libs/libpng12_la-pngtrans.o .libs/libpng12_la-pngwutil.o .libs/libpng12_la-pngread.o .libs/libpng12_la-pngrio.o .libs/libpng12_la-pngwio.o .libs/libpng12_la-pngwrite.o .libs/libpng12_la-pngrtran.o .libs/libpng12_la-pngwtran.o .libs/libpng12_la-pngmem.o .libs/libpng12_la-pngerror.o .libs/libpng12_la-pngpread.o -lz -lm -Wl,--version-script=libpng.vers -Wl,-soname -Wl,libpng12.so.0 -o .libs/libpng12.so.0.31.0
/usr/bin/ld: /usr/local/lib/libz.a(crc32.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libz.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[1]: *** [libpng12.la] Error 1
make[1]: Leaving directory `/lamp/libpng-1.2.31'
make: *** [all] Error 2
使用网上的帖子在编译时加上CFLAGS="-O3 -fPIC" ./configure ,然后再make也不行
[root@localhost libpng-1.2.31]# make
make all-am
make[1]: Entering directory `/lamp/libpng-1.2.31'
/bin/sh ./libtool --tag=CC --mode=link gcc -g -O2 -no-undefined -export-dynamic -version-number 0:31:0 -Wl,--version-script=libpng.vers -o libpng12.la -rpath /usr/local/libpng/lib libpng12_la-png.lo libpng12_la-pngset.lo libpng12_la-pngget.lo libpng12_la-pngrutil.lo libpng12_la-pngtrans.lo libpng12_la-pngwutil.lo libpng12_la-pngread.lo libpng12_la-pngrio.lo libpng12_la-pngwio.lo libpng12_la-pngwrite.lo libpng12_la-pngrtran.lo libpng12_la-pngwtran.lo libpng12_la-pngmem.lo libpng12_la-pngerror.lo libpng12_la-pngpread.lo -lz -lm
libtool: link: gcc -shared .libs/libpng12_la-png.o .libs/libpng12_la-pngset.o .libs/libpng12_la-pngget.o .libs/libpng12_la-pngrutil.o .libs/libpng12_la-pngtrans.o .libs/libpng12_la-pngwutil.o .libs/libpng12_la-pngread.o .libs/libpng12_la-pngrio.o .libs/libpng12_la-pngwio.o .libs/libpng12_la-pngwrite.o .libs/libpng12_la-pngrtran.o .libs/libpng12_la-pngwtran.o .libs/libpng12_la-pngmem.o .libs/libpng12_la-pngerror.o .libs/libpng12_la-pngpread.o -lz -lm -Wl,--version-script=libpng.vers -Wl,-soname -Wl,libpng12.so.0 -o .libs/libpng12.so.0.31.0
/usr/bin/ld: /usr/local/lib/libz.a(crc32.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libz.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[1]: *** [libpng12.la] Error 1
make[1]: Leaving directory `/lamp/libpng-1.2.31'
make: *** [all] Error 2
使用网上的帖子在编译时加上CFLAGS="-O3 -fPIC" ./configure ,然后再make也不行
|
/usr/bin/ld: /usr/local/lib/libz.a(crc32.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
re-install libz, ld can't find the share library of libz.so. instead, it tried to link the static library, which was definitely not compiled with position independent code option
re-install libz, ld can't find the share library of libz.so. instead, it tried to link the static library, which was definitely not compiled with position independent code option
|
/usr/local/lib/libz.a: could not read symbols: Bad value(64 位 Linux)
/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]#