Centos: ZLIB_1.2.9 not found

悠扬的幻想天空 - 博客

March 29, 2022 技术 • 作者:悠扬

下载 vue-vben-admin 依赖时候发生如下报错:

error /root/tensuu/vue-vben-admin/node_modules/mozjpeg: Command failed.
Exit code: 1
Command: node lib/install.js
Arguments: 
Directory: /root/tensuu/vue-vben-admin/node_modules/mozjpeg
Output:
Command failed: /root/tensuu/vue-vben-admin/node_modules/mozjpeg/vendor/cjpeg -version
/root/tensuu/vue-vben-admin/node_modules/mozjpeg/vendor/cjpeg: /lib64/libz.so.1: version `ZLIB_1.2.9' not found (required by /root/tensuu/vue-vben-admin/node_modules/mozjpeg/vendor/cjpeg)


mozjpeg pre-build test failed
compiling from source
Error: Command failed: /bin/sh -c ./configure --enable-static --disable-shared --disable-dependency-tracking --with-jpeg8  --prefix="/root/tensuu/vue-vben-admin/node_modules/mozjpeg/vendor" --bindir="/root/tensuu/vue-vben-admin/node_modules/mozjpeg/vendor" --libdir="/root/tensuu/vue-vben-admin/node_modules/mozjpeg/vendor"
configure: error: no nasm (Netwide Assembler) found

解决问题

报错提示表明在/lib64/libz.so.1中缺少ZLIB_1.2.9或更高版本,具体包含哪些版本可以使用如下命令查看:

[root@VM-234-97-centos ~]# strings /lib64/libz.so.1 |grep "ZLIB*"
  ZLIB_1.2.0
  ZLIB_1.2.0.2
  ZLIB_1.2.0.8
  ZLIB_1.2.2
  ZLIB_1.2.2.3
  ZLIB_1.2.2.4
  ZLIB_1.2.3.3
  ZLIB_1.2.3.4
  ZLIB_1.2.3.5
  ZLIB_1.2.5.1
  ZLIB_1.2.5.2

通过输出结果发现缺少是没有相应的版本。

解决这个问题的方法非常简单,总的来说就是查找和替换,使用带有ZLIB_1.2.9或更高版本替换/lib64/libz.so.1

# 查找
[root@VM-234-97-centos ~]# find / -name "libz.so.1"
/root/.cache/JetBrains/RemoteDev/dist/cc5fad945d7ec_goland-2021.3.3/plugins/remote-dev-server/selfcontained/lib/libz.so.1
/root/.cache/JetBrains/RemoteDev/dist/e3adf6bf629c5_WebStorm-2021.3.2/plugins/remote-dev-server/selfcontained/lib/libz.so.1
/root/download/ft_local/zlib-1.2.9/libz.so.1
/usr/lib64/libz.so.1
/usr/local/lib/libz.so.1
/usr/1.2-compat/lib64/libz.so.1
/usr/1.2-compat/lib/libz.so.1
/usr/lib/x86_64-redhat-linux6E/libz.so.1
/usr/lib/libz.so.1

# 确认其中的某一个libz.so.1含有ZLIB_1.2.9
[root@VM-234-97-centos ~]# strings /usr/local/lib/libz.so.1 |grep "ZLIB*"
ZLIB_1.2.0
ZLIB_1.2.0.2
ZLIB_1.2.0.8
ZLIB_1.2.2
ZLIB_1.2.2.3
ZLIB_1.2.2.4
ZLIB_1.2.3.3
ZLIB_1.2.3.4
ZLIB_1.2.3.5
ZLIB_1.2.5.1
ZLIB_1.2.5.2
ZLIB_1.2.7.1
ZLIB_1.2.9
ZLIB_1.2.0
ZLIB_1.2.2
ZLIB_1.2.5.2
ZLIB_1.2.3.5
ZLIB_1.2.3.3
ZLIB_1.2.2.3
ZLIB_1.2.0.8
ZLIB_1.2.7.1
ZLIB_1.2.0.2
ZLIB_1.2.9
ZLIB_1.2.5.1
ZLIB_1.2.3.4
ZLIB_1.2.2.4

# 也可以使用ln -s来创建软连接
[root@VM-234-97-centos ~]# cp /usr/local/lib/libz.so.1 /usr/lib64/
参考来源:http://showteeth.tech/posts/741.html
或者尝试安装 nasm

添加新评论