问题描述
我的应用程序使用Mochiweb。我注意到Mochiweb文件位于 myapp / deps / mochiweb
目录和 rebar
当我在 myapp
目录中运行make时编译它们。
我想添加 ibrowse
来编写一些使http请求到我的应用程序的测试。所以我从github克隆 ibrowse
到 myapp / deps / ibrowse
目录。
但是,似乎Erlang不知道从哪里获得 ibrowse
的 .beam
文件,因此我所有使用 ibrowse
模块的测试失败:
myapp
ebin %%编译测试驻留在这里,使用ibrowse失败(badarg)的测试
deps
mochiweb
ibrowse
ebin %%编译的ibrowse模块驻留在
src
测试
如何使我的基于Mochiweb的应用程序使用其他Erlang / OTP外部库?
我应该为此编辑rebar.config或Makefile吗?或者也许我应该编辑一个_app.src文件?
编辑:也许我应该编辑myapp_sup.erl文件中的目录列表? ( myapp_deps:local_path([priv,www]
)
PS我的应用程序如何知道哪里所有mochiweb.beam文件都驻留在(例如,通用的 myapp_web.erl
使用调用 mochiweb_http
模块,但在 myapp / ebin
目录中没有 mochiweb_http.beam
。
将以下代码添加到myapp_web.erl中解决了我的问题:
ibrowse:start()
默认情况下Mochiweb在同一个函数中启动:
mochiweb_http:start()...
我不知道它是否是正确的方法,但它的作品。
My app uses Mochiweb.
I have noticed that Mochiweb files reside in the myapp/deps/mochiweb
directory and rebar
compiles them when I run make in the myapp
directory.
I wanted to add ibrowse
to write a few tests which make http requests to my app. So I cloned ibrowse
from github to myapp/deps/ibrowse
directory.
But it seems that Erlang does not know where to get the .beam
files for ibrowse
and therefore all my tests that use the ibrowse
module fail:
myapp
ebin %%compiled tests reside here, tests which use ibrowse fail (badarg)
deps
mochiweb
ibrowse
ebin %%compiled ibrowse module resides here
src
tests
How can I make my Mochiweb-based app use other Erlang/OTP external libraries?
Should I edit rebar.config or Makefile for that? Or maybe I should edit an _app.src file?
Edit: Maybe I should edit the list of directories in the myapp_sup.erl file? (myapp_deps:local_path(["priv", "www"]
)
P.S. How does my app know where all the mochiweb.beam files reside? (for example, the generic myapp_web.erl
uses a call to mochiweb_http
module, but there is no mochiweb_http.beam
in the myapp/ebin
directory).
Adding the following code to myapp_web.erl solved my problem:
ibrowse:start()
By default Mochiweb is started in the same function:
mochiweb_http:start()...
I am not sure if it the proper way to do this, but it works.
这篇关于Mochiweb:包含并编译其他库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!