php 8.2 从源码安装 ffi 扩展

按原有安装扩展的的操作方法

cd /Users/wxm/Downloads/code-src/php-8.2.8/ext/ffi

/opt/softwares/php82/bin/phpize ./

./configure --with-php-config=/opt/softwares/php82/bin/php-config

然后 提示

checking for FFI support... yes, shared
checking for libffi >= 3.0.11... no
configure: error: Package requirements (libffi >= 3.0.11) were not met:

Requested 'libffi >= 3.0.11' but version of libffi is 2.1

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables FFI_CFLAGS
and FFI_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

而 本地已经安装了 高版本的 libffi 不知道为什么找不到, 查了一些资料. 网上讲的 都太笼统 没有一个完全可行的方法, 文章内容转来转去.

先查本地的安装路径:

➜ ffi brew --prefix libffi
/usr/local/opt/libffi

再查 系统当前默认的路径

➜ ffi pkg-config --cflags libffi
-I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/ffi

发现对不上, 那就强制指定为新版本的吧

临时 设置 依赖库

export FFI_CFLAGS="-I/usr/local/opt/libffi/include"
export FFI_LIBS="-L/usr/local/opt/libffi/lib -lffi"

./configure --with-php-config=/opt/softwares/php82/bin/php-config
make -j3 && make install

就安装好了

在这里插入图片描述

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐