在安装Swoole时出现 libbrotlienc
依赖缺失的问题,提示一下错误:
configure: error: Package requirements (libbrotlienc) were not met:
No package 'libbrotlienc' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables BROTLIENC_CFLAGS
and BROTLIENC_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
make: *** No targets specified and no makefile found. Stop.
error
分步解决方案:
1. 安装系统依赖
根据你的Linux发行版执行以下命令:
Debian/Ubuntu 系统
# 安装开发库
sudo apt update
sudo apt install -y libbrotli-dev pkg-config
# 安装编译工具链
sudo apt install -y build-essential autoconf automake
CentOS/RHEL 系统
# 安装开发库
sudo yum install -y brotli-devel pkgconfig
# 安装编译工具链
sudo yum groupinstall -y "Development Tools"
2. 验证依赖是否存在
# 检查头文件是否存在(Ubuntu)
ls /usr/include/brotli/encode.h
# 检查库文件是否存在(Ubuntu)
ls /usr/lib/x86_64-linux-gnu/libbrotlienc.so
# CentOS路径可能为
ls /usr/lib64/libbrotlienc.so
3. 手动指定依赖路径(如果自动检测失败)
如果确认已安装但依然报错,临时设置环境变量:
export BROTLIENC_CFLAGS="-I/usr/include/brotli"
export BROTLIENC_LIBS="-lbrotlienc"
然后重新运行Swoole的编译流程