OSX下brew多版本切换时提示libjpeg错误的解决办法

错误提示

1
2
3
4
5
php -v
dyld: Library not loaded: /usr/local/opt/jpeg/lib/libjpeg.8.dylib
Referenced from: /usr/local/bin/php
Reason: image not found
Abort trap: 6

如果是单一版本的php,可以简单的通过切换libjpeg的版本解决

1
2
3
4
5
6
7
8
9
> brew info libjpeg
jpeg: stable 9c (bottled)
Image manipulation library
http://www.ijg.org
/usr/local/Cellar/jpeg/8d (19 files, 731KB)
Poured from bottle on 2014-10-18 at 04:30:18
/usr/local/Cellar/jpeg/9c (21 files, 724.5KB) *
Poured from bottle on 2018-05-03 at 09:42:58
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/jpeg.rb
1
> brew switch jpeg 8d

但如果是多版本php共存,这样处理可能会导致某个版本的php修复了,另一个版本缺报错。因为两者使用的libjpeg不一致,这种情况可以简单的通过重新编译其中一版php解决.

1
> brew upgrade php@7.1

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×