macbook M1芯片 arm64 安装部分软件出错的解决方案
作者:互联网
M1芯片默认使用的arm64架构,可以使用如下命令查看:uname -a
当我安装了brew(https://www.cnblogs.com/rxbook/p/16377843.html),
再使用brew安装kafka、librdkafka的时候,都是没问题的,参考 https://www.cnblogs.com/rxbook/p/10877784.html
然后安装完php-rdkafka扩展的时候,也没报错,但是使用php -m 查看是否安装成功的时候 却出错了:
Warning: PHP Startup: Unable to load dynamic library 'rdkafka.so' (tried: /Applications/MxSrvs/bin/php/ext/rdkafka.so (dlopen(/Applications/MxSrvs/bin/php/ext/rdkafka.so, 0x0009): tried: '/Applications/MxSrvs/bin/php/ext/rdkafka.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))), /Applications/MxSrvs/bin/php/ext/rdkafka.so.so (dlopen(/Applications/MxSrvs/bin/php/ext/rdkafka.so.so, 0x0009): tried: '/Applications/MxSrvs/bin/php/ext/rdkafka.so.so' (no such file))) in Unknown on line 0
大致意思就是已经安装了arm64架构的,但是需要x86_64架构的。折腾了五六个小时,总算找到了解决方案,必须得记录下来,以备后用:
https://blog.csdn.net/qq_41017902/article/details/123458089
在终端中执行命令arch -x86_64 zsh
来切换架构,切换之后,再查看 uname -a :
然后再重新安装x86的brew、kafka、librdkafka、php-rdkafka
参考:http://t.zoukankan.com/jinzhao-p-15662791.html
X86 HomeBrew
$ arch -x86_64 zsh
$ cd /usr/local && mkdir homebrew
$ curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
Alias快捷别名(vim ~/.zshrc)
alias
ibrew='arch -x86_64 /usr/local/bin/brew'alias
izsh='arch -x86_64 zsh'alias
azsh='arch -arm64e zsh'
完了之后再重复上面的php-rdkafka的安装步骤就好了。
标签:bin,x86,Applications,rdkafka,so,arm64,M1,php,macbook 来源: https://www.cnblogs.com/rxbook/p/16401878.html