CentOS下编译PHP 7.4报错Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met

错误分析

错误日志:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
checking for zip archive read/write support... yes
checking for libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0... no
configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:

No package 'libzip' found
No package 'libzip' found
No package 'libzip' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBZIP_CFLAGS
and LIBZIP_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

原因分析:CentOS 7上自带或通过yum安装的libzip版本过低

解决方法

(1)查看是否有安装过libzip

1
2
rpm -q libzip
rpm -q libzip-devel

如果有,卸载它

1
yum remove libzip-devel libzip

(2)然后从官网下载并编译安装

1
2
3
4
5
wget https://libzip.org/download/libzip-1.3.2.tar.gz
tar zxf libzip-1.3.2.tar.gz
cd libzip-1.3.2
./configure
make && make install

如果是下载1.5.*以上版本,则需要采用如下安装方式

1
2
3
4
5
6
7
8
yum -y install cmake
wget https://libzip.org/download/libzip-1.5.2.tar.gz
tar zxf libzip-1.5.2.tar.gz
cd libzip-1.5.2
mkdir build
cd build
cmake ..
make && make install

(3)查看libzip安装位置

1
2
# whereis libzip
libzip: /usr/local/lib/libzip.la /usr/local/lib/libzip.a /usr/local/lib/libzip.so

(4)动态链接库添加为系统共享

1
2
3
# echo "/usr/local/lib" >>/etc/ld.so.conf
# ldconfig -v | grep libzip
# export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:$PKG_CONFIG_PATH

(5)也可以安装rpm包

1
2
3
yum remove libzip libzip-devel
yum install https://rpms.remirepo.net/enterprise/7/remi/x86_64/libzip5-1.7.0-1.el7.remi.x86_64.rpm
yum install https://rpms.remirepo.net/enterprise/7/remi/x86_64/libzip5-devel-1.7.0-1.el7.remi.x86_64.rpm

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :