libpng-1.6.36源码编译安装

本次安装基于系统CentOS Linux release 6.0 (Final)

1.下载源码

官网地址: http://www.libpng.org/

2.解压源码

$ tar zxvf libpng-1.6.36.tar.gz

3.编译前配置

$ cd libpng-1.6.36
$ ./configure --prefix=$HOME/local/prior

4.编译源码

$ make

发生报错

libtool: link: gcc -g -O2 -o .libs/pngfix contrib/tools/pngfix.o  ./.libs/libpng16.so -lz -lm -Wl,-rpath -Wl,/home/freetype/local/prior/lib
contrib/tools/pngfix.o: In function `zlib_reset':
/home/freetype/downloads/libpng-1.6.36/contrib/tools/pngfix.c:2184: undefined reference to `inflateReset2'
./.libs/libpng16.so: undefined reference to `inflateValidate'
collect2: ld returned 1 exit status
make[1]: *** [pngfix] Error 1
make[1]: Leaving directory `/home/freetype/downloads/libpng-1.6.36'
make: *** [all] Error 2

5.修改configure

通过观察发现关键字zlib,百度之后,修改configure指定参数

$ make clean
$ LDFLAGS="-L$HOME/local/prior/lib" CPPFLAGS="-I$HOME/local/prior/include" ./configure --prefix=$HOME/local/prior

让程序编译时链接上次安装的zlib库, 而不是链接系统内的zlib库

6.重新编译

$ make

7.安装libpng

$ make install

你可能感兴趣的:(libpng-1.6.36源码编译安装)