我试图在模块中使用mochiweb,但是找不到让模块“意识到”mochiweb的方法。
mochiweb_html:parse("<XML>").这在erl中工作得很好,但是当我在模块中使用undefined function时,我会一直得到它。
发布于 2011-11-27 21:26:39
如果我理解你的问题,听起来就像是代码路径问题。只要mochiweb_html.beam在您的代码路径中,您就可以使用任何导出函数。
从erlang (erlang,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 (-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"https://stackoverflow.com/questions/8284225
复制相似问题