一,报错的例子:
1,报错信息
[root@localhost work]# identify -list format
identify: error while loading shared libraries: libjpeg.so.9: cannot open shared object file: No such file or directory
2,原因:
imagemagick在调用jpeg的动态链接库时找不到相应的文件,所以报错
3,查看libjpeg:通常放在/usr/local/lib/
[root@localhost work]# ls /usr/local/lib/libjpeg.so*
/usr/local/lib/libjpeg.so /usr/local/lib/libjpeg.so.9 /usr/local/lib/libjpeg.so.9.5.0
二,解决办法一:临时解决:
[root@localhost work]# ldconfig /usr/local/lib
再次执行identify命令可以正常执行
[root@localhost work]# identify -list format
Format Mode Description
...
说明:刘宏缔的架构森林—专注it技术的博客,
网站:https://blog.imgtouch.com
原文: https://blog.imgtouch.com/index.php/2023/07/12/imagemagick-bao-cuo-error-while-loading-shared-libraries-libjpeg-so-9-imagemagick-7-1-rocky-linux-9/
代码: https://github.com/liuhongdi/ 或 https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: 371125307@qq.com
三,解决办法二:永久解决:保存库的路径
在/etc/ld.so.conf.d/目录下新建一个lib.conf文件,
添加libjpeg库所在的目录/usr/local/lib到文件中
[root@localhost etc]# cd /etc/ld.so.conf.d/
[root@localhost ld.so.conf.d]# pwd
/etc/ld.so.conf.d
[root@localhost ld.so.conf.d]# vi lib.conf
[root@localhost ld.so.conf.d]# more lib.conf
/usr/local/lib
添加完成后使生效:
[root@localhost ld.so.conf.d]# ldconfig -v
ldconfig: 无法对 /libx32 进行 stat 操作: 没有那个文件或目录
ldconfig: 多次给出路径“/usr/lib”
(from <builtin>:0 and <builtin>:0)
ldconfig: 多次给出路径“/usr/lib64”
(from <builtin>:0 and <builtin>:0)
ldconfig: 无法对 /usr/libx32 进行 stat 操作: 没有那个文件或目录
/usr/local/lib: (from /etc/ld.so.conf.d/lib.conf:1)
libtiffxx.so.6 -> libtiffxx.so.6.0.1
libtiff.so.6 -> libtiff.so.6.0.1
libjpeg.so.9 -> libjpeg.so.9.5.0
libwebpdemux.so.2 -> libwebpdemux.so.2.0.13
libwebpmux.so.3 -> libwebpmux.so.3.0.12
libwebp.so.7 -> libwebp.so.7.1.7
libsharpyuv.so.0 -> libsharpyuv.so.0.0.1
...
四,查看linux的版本:
[root@localhost ImageMagick-7.1.1-12]# cat /etc/redhat-release
Rocky Linux release 9.2 (Blue Onyx)
- ImageMagick libraries loading libjpeg sharedimagemagick libraries loading libjpeg shared file libraries loading shared libraries loading libxml2 shared permission libraries loading shared libreadline libraries loading shared libraries loading libpcre shared file directory libraries glibcxx library unable shared jenkins library share shared libraries libcrypto bcftools