2011-11-27 34 views
0

我正在嘗試在模塊中使用mochiweb,但無法找到使模塊「知道」mochiweb的方法。未定義的函數mochiweb_html:解析/ 1

mochiweb_html:parse("<XML>"). 

ERL工作正常,但我不斷收到undefined function當我使用它一個模塊內。

回答

0

如果我明白你的問題,這聽起來像一個代碼路徑問題。只要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的目錄是在你的代碼路徑。

將其添加到您的代碼路徑,使用命令林德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" 

或使用代碼模塊(代碼:add_patha,代碼: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"