You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

编译emqtt作为EMQX SDK客户端时Makefile编译报错求助

编译emqtt客户端依赖失败的解决办法

问题场景

在Debian 10系统(已部署Erlang/OTP 25、系统级rebar3)编译emqtt源码时,执行make命令出现依赖拉取失败,核心错误为无法获取指定commit的gun仓库版本,且rebar.conf声明的gun版本与rebar.lock锁定版本存在差异。


解决步骤

1. 清理本地构建缓存

先清除旧的构建文件和依赖锁定信息,避免缓存干扰:

make distclean

若make命令无法执行,手动删除相关文件:

rm -rf _build rebar.lock rebar3

2. 统一gun依赖版本

修改rebar.conf中的gun依赖配置,使其与rebar.lock中锁定的commit一致:

{deps, [{cowlib, "2.12.1"},
        {gun, {git, "https://github.com/emqx/gun", {ref, "4faea40b9a8ca1eac5288355f8202e0cea379d50"}}},
        {getopt, "1.0.2"}
       ]}.

3. 手动拉取gun依赖(可选)

如果rebar3自动拉取失败,手动克隆指定版本的gun到依赖目录:

mkdir -p _build/default/lib/
cd _build/default/lib/
git clone https://github.com/emqx/gun.git
cd gun && git checkout 4faea40b9a8ca1eac5288355f8202e0cea379d50
cd ../../../../

4. 使用项目指定版本的rebar3编译

Makefile中指定了rebar3 3.19.0,系统级版本可能存在兼容性问题,让脚本自动下载对应版本:

rm -f rebar3
make compile

5. 避免用root权限编译

root用户可能存在网络或git权限限制,切换回普通用户执行编译:

su erlang # 切换到你的普通用户账号
make compile

内容的提问来源于stack exchange,提问作者Alberto Perri

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 08:25:55