dyld:库未加载:/usr/local/lib/libjpeg.8.dylib - 自制 php
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32703296/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
dyld: Library not loaded: /usr/local/lib/libjpeg.8.dylib - homebrew php
提问by Snowcrash
PHP was not working for me as I was encountering this libpng issue, so I reinstalled a new version with Homebrew.
当我遇到这个 libpng 问题时,PHP 对我不起作用,所以我用 Homebrew 重新安装了一个新版本。
However, I'm getting a similar error with libjpeg
this time:
但是,libjpeg
这次我遇到了类似的错误:
$ php -v
dyld: Library not loaded: /usr/local/lib/libjpeg.8.dylib
Referenced from: /usr/local/bin/php
Reason: image not found
Trace/BPT trap: 5
Any suggestions?
有什么建议?
回答by Denis Pitzalis
As proposed by @jirson-tavera in the homebrew-php repo issue, this can be fixed without overriding your brew installation:
正如@jirson-tavera 在homebrew-php repo issue 中提出的,这可以在不覆盖您的 brew 安装的情况下修复:
wget -c http://www.ijg.org/files/jpegsrc.v8d.tar.gz
tar xzf jpegsrc.v8d.tar.gz
cd jpeg-8d
./configure
make
cp ./.libs/libjpeg.8.dylib /usr/local/opt/jpeg/lib
回答by sepehr
Even though the solution in the accepted answer works, it's not the right way to fix the problem. It violates brew's metadata integrity.
即使已接受答案中的解决方案有效,也不是解决问题的正确方法。它违反了 brew 的元数据完整性。
Problem
问题
The issue is that Homebrew's jpeg
formula has been upgraded to v9 but the existing "bottled" PHP formula is still built and linked against the previous version, v8, which is no longer exists on your system.
问题是 Homebrew 的jpeg
公式已升级到 v9,但现有的“瓶装”PHP 公式仍在构建并链接到以前的版本 v8,该版本已不再存在于您的系统中。
You have a few options to fix the issue.
您有几个选项可以解决此问题。
1. Recompile phpxx
formula from source (highly recommended)
1.phpxx
从源代码重新编译公式(强烈推荐)
Uninstall your php formula, and rebuild it from the source instead of using the bottled version. This way, php will use and link against the currently installed version of jpeg
. Assuming that you're dealing with php71
:
卸载您的 php 公式,并从源代码重建它,而不是使用瓶装版本。这样,php 将使用并链接到当前安装的jpeg
. 假设您正在处理php71
:
brew reinstall php71 --build-from-source
2. Downgrade jpeg
formula the right way (preferred over recompiling it manually)
2.jpeg
以正确的方式降级公式(优先于手动重新编译)
If you haven't run brew cleanup
, you already got the previous jpeg
version in your brew's cellar, switch to it:
如果你还没有运行brew cleanup
,你已经jpeg
在你的 brew 的地窖里得到了以前的版本,切换到它:
brew switch jpeg 8d
If you get a jpeg does not have a version "8d" in the Cellar.
error, you need to first restore it by reverting the history:
如果出现jpeg does not have a version "8d" in the Cellar.
错误,您需要先通过恢复历史记录来恢复它:
cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core
git checkout b231469
HOMEBREW_NO_AUTO_UPDATE=1 brew install jpeg
git checkout master
brew switch jpeg 8d
You can find out the commit hash by using brew log jpeg
and going through the commit messages.
您可以通过使用brew log jpeg
和浏览提交消息来找出提交哈希。
The downside is that there might be other formulas that require the newer version to work properly, e.g. imagemagick
. If you face such incompatibility issues, check the first solution above.
缺点是可能有其他公式需要较新版本才能正常工作,例如imagemagick
. 如果您遇到此类不兼容问题,请查看上面的第一个解决方案。
3. Downgrade jpeg
by manually recompiling (not recommended)
3.jpeg
手动重新编译降级(不推荐)
Fetch the source, compile and overwrite brew's version. Refer to Denis' answerfor details.
获取源代码,编译并覆盖 brew 的版本。有关详细信息,请参阅丹尼斯的回答。
This is not recommended because it violates the integrity of your brew metadata. Brew thinks that it has the 8b version, however, you manually compiled 9b and overwrote the files.
不建议这样做,因为它违反了 brew 元数据的完整性。Brew 认为它有 8b 版本,但是,您手动编译了 9b 并覆盖了文件。
4. Manually symlink the old version (seriously?)
4.手动符号链接旧版本(认真的?)
Do not manually symlinkthe leftover libjpeg.8.dylib
. If the file is there, you can just brew switch
to it as mentioned in the second solution above.
不要手动符号链接剩余的libjpeg.8.dylib
. 如果文件在那里,您可以brew switch
按照上面的第二个解决方案中提到的方式使用它。
It's just the worst hack you can do here.
这只是你在这里可以做的最糟糕的黑客攻击。
Such issues will be eventually fixed.
此类问题最终将得到解决。
回答by Pawe? Wac?awczyk
I encountered the similar problem today. The cause of the problem was a newer version of libjpeg
. And the solution that worked was building php
bottle from source.
我今天遇到了类似的问题。问题的原因是更新版本的libjpeg
. 有效的解决方案是php
从源头构建瓶子。
Check available version of libjpeg
:
检查可用版本libjpeg
:
$brew info libjpeg
jpeg: stable 9b (bottled)
Image manipulation library
http://www.ijg.org
/usr/local/Cellar/jpeg/9b (20 files, 724KB) *
Poured from bottle on 2017-08-07 at 12:06:42
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/jpeg.rb
Install php
from source:
php
从源安装:
brew install --build-from-source php56
Update:
If you have already installed php
you have to uninstall it prior to building from source. It also applies to extensions.
更新:
如果您已经安装php
,则必须在从源代码构建之前卸载它。它也适用于扩展。
回答by Jorge Lobo
A dirty solution, that work fine for me.
一个肮脏的解决方案,对我来说很好用。
ln -s /usr/local/lib/libjpeg.9.dylib /usr/local/lib/libjpeg.8.dylib
回答by Jirson Tavera
I had the same problem and I solved it by downloading the libjpeg tarball manuallu from hereand running:
我遇到了同样的问题,我通过从这里下载 libjpeg tarball manuallu并运行来解决它:
tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
cp /usr/share/libtool/config.sub .
cp /usr/share/libtool/config.guess .
./configure --enable-shared --enable-static
make
sudo make install
sudo ranlib /usr/local/lib/libjpeg.a #Optionally
回答by GabLeRoux
I was getting a similar problem trying to upgrade composer
:
我在尝试升级时遇到了类似的问题composer
:
dyld: Library not loaded: /usr/local/opt/jpeg/lib/libjpeg.8.dylib
Referenced from: /usr/local/bin/php
Reason: image not found
composer: PHP Phar support is required for this formula
Error: An unsatisfied requirement failed this build.
dyld:库未加载:/usr/local/opt/jpeg/lib/libjpeg.8.dylib
引用自:/usr/local/bin/php
原因:找不到图像
作曲家:此公式需要 PHP Phar 支持
错误:未满足的要求未能通过此构建。
Problem was php
couldn't find libjpeg
library anymore. One way to fix this is to reinstall php
and libjpeg
. Here's how I reinstalled them:
问题是php
再也找不到libjpeg
图书馆了。解决此问题的一种方法是重新安装php
和libjpeg
. 这是我重新安装它们的方法:
# find out which version of php is installed
brew list | grep php
# uninstall php
brew uninstall php70 --ignore-dependencies
# uninstall libjpeg
brew uninstall libjpeg --ignore-dependencies
# install libjpeg again
brew install libjpeg
# install php again
brew install php70
I was then able to upgrade everything again :)
然后我能够再次升级所有东西:)
brew update && brew upgrade
回答by Pankaj Agrawal
Following command worked for me.
以下命令对我有用。
brew switch libjpeg 8d
回答by gwg
I didn't try Jirson's answer, but what worked for me was:
我没有尝试 Jirson 的回答,但对我有用的是:
brew uninstall libjpeg
brew install libjpeg
回答by martin
I was having the same problem and the only thing that helped was to use the --build-from-source
parameter:
我遇到了同样的问题,唯一有帮助的是使用--build-from-source
参数:
brew install php70 --build-from-source