【发布时间】:2012-01-07 05:25:55
【问题描述】:
我正在尝试在模块中使用 mochiweb,但找不到让模块“感知”mochiweb 的方法。
mochiweb_html:parse("<XML>").
这在 erl 中运行良好,但是当我在模块中使用它时,我不断收到 undefined function。
【问题讨论】:
标签: erlang
我正在尝试在模块中使用 mochiweb,但找不到让模块“感知”mochiweb 的方法。
mochiweb_html:parse("<XML>").
这在 erl 中运行良好,但是当我在模块中使用它时,我不断收到 undefined function。
【问题讨论】:
标签: erlang
如果我理解您的问题,这听起来像是代码路径问题。只要 mochiweb_html.beam 在您的代码路径中,您就可以使用任何导出的函数。
从 erlang shell (erl) 运行它可能有效,因为光束文件在您的 cwd 中。
例如:
# cd /home/blah/src/mochiweb/ebin; erl
1> code:where_is_file("mochiweb_html.beam").
"./mochiweb_html.beam"
# cd /tmp; erl
1> code:where_is_file("mochiweb_html.beam").
non_existing
确保包含 mochiweb_html.beam 的目录位于您的代码路径中。
要将其添加到您的代码路径,请使用命令 lind args (-pa, -pz):
# erl -pa /home/blah/src/mochiweb/ebin
1> code:where_is_file("mochiweb_html.beam").
"/home/blah/src/mochiweb/ebin/mochiweb_html.beam"
或使用代码模块(code:add_patha, code:add_pathz):
# erl
1> code:where_is_file("mochiweb_html.beam").
non_existing
2> code:add_patha("/home/blah/src/mochiweb/ebin/").
true
3> code:where_is_file("mochiweb_html.beam").
"/home/blah/src/mochiweb/ebin/mochiweb_html.beam"
【讨论】: