无法为Mongooseim添加依赖[erlang]

时间:2014-08-18 10:01:58

标签: erlang ejabberd rebar mongoose-im

您好我正在为mongooseim(ejabberd fork)聊天编写模块,我想从github获取一些外部库。我把它添加到rebar配置。

    {jsx, ".*", {git, "git://github.com/talentdeficit/jsx", {branch, "master"}}}

它正在下载到/ deps目录,而当我运行项目时出现以下错误:call to undefined function jsx:encode

我找到/ ebin目录复制的目录(/ dev / lib / ebin)并从那里复制jsx的ebin目录。然后可以访问功能。每次都不可能手动执行此操作,如何使用钢筋进行此操作?谢谢。

更新 我实际上用make dev rel构建它:

发生以下情况:

devrel: $(DEVNODES)

$(DEVNODES): rebar deps compile deps_dev
    @echo "building $@"
    (cd rel && ../rebar generate -f target_dir=../dev/mongooseim_$@ overlay_vars=./reltool_vars/$@_vars.config)
    cp apps/ejabberd/src/*.erl `ls -dt dev/mongooseim_$@/lib/ejabberd-2.1.8*/ebin/ | head -1`
ifeq ($(shell uname), Linux)
    cp -R `dirname $(shell readlink -f $(shell which erl))`/../lib/tools-* dev/mongooseim_$@/lib/
else
    cp -R `which erl`/../../lib/tools-* dev/mongooseim_$@/lib/
endif

1 个答案:

答案 0 :(得分:2)

为了向mongooseim添加依赖项,您应首先将其添加到 rebar.config

{deps, [
    {cuesport, ".*", {git, "git://github.com/goj/cuesport.git", {branch, "master"}}},
    {redo, ".*", {git, "git://github.com/JacobVorreuter/redo.git", {branch, "master"}}},
    {exml, "2.1.4", {git, "git://github.com/esl/exml.git", {tag, "2.1.4"}}},
    {lager, ".*", {git, "git://github.com/basho/lager.git"}},
    {cowboy, "0.8.6", {git, "git://github.com/extend/cowboy.git", "0.8.6"}},
    {folsom, ".*", {git, "git://github.com/boundary/folsom.git", {branch, "master"}}},
    {mochijson2, ".*", {git, "git://github.com/bjnortier/mochijson2.git", {branch, "master"}}},
    {alarms, ".*", {git, "git://github.com/chrzaszcz/alarms.git", {branch, "master"}}},
    {p1_cache_tab, ".*", {git, "git://github.com/processone/cache_tab"}},
    {p1_stringprep, ".*", {git, "git://github.com/processone/stringprep.git", "9e9e0f8dbe6a70ef36e1d4436b458ca5a77fbcfb"}},
    My dependency-->{jsx, ".*", {git, "git://github.com/talentdeficit/jsx", {branch, "master"}}}
]}.

然后当你make时,它应该被下载到 / deps 目录。

然后看一下/rel/reltool.config文件。

在这里您可以找到类似的内容:

{sys, [ ...
   {app, inets, [{incl_cond, include}]},
   {app, exml, [{incl_cond, include}]},
   {app, ranch, [{incl_cond, include}]},
   {app, cowboy, [{incl_cond, include}]},
   {app, bear, [{incl_cond, include}]},
   {app, folsom, [{incl_cond, include}]},
   {app, mochijson2, [{incl_cond, include}]},
   {app, syntax_tools, [{incl_cond, include}]},
   {app, p1_cache_tab, [{incl_cond, include}]},
   {app, alarms, [{incl_cond, include}]},
   My dependency->{app, jsx, [{incl_cond, include}]}
}

你的依赖应该有效。查看 rel / mongooseim / lib dev / mongooseim_odbc * / lib 目录。在我的例子中,有一个带有 ebin 目录的jsx-2.0.1。