Compilation erlang-如何编译&;在代码中加载外部模块

Compilation erlang-如何编译&;在代码中加载外部模块,compilation,erlang,Compilation,Erlang,我想编译并加载mod.erlfromtest\u mod.erl 我试着这样做: -module(mod_test). -export([test/0]). test()-> compile:file(mod), mod:start(). 但是如果它不起作用你就不能把表达式放在模块的顶层;您需要将它们包含在函数中,如下所示: -module(mod_test). -export([compile_and_load_mod/0]). c

我想编译并加载mod.erlfromtest\u mod.erl

我试着这样做:

 -module(mod_test).
 -export([test/0]).   

 test()->
         compile:file(mod),
         mod:start().

但是如果它不起作用

你就不能把表达式放在模块的顶层;您需要将它们包含在函数中,如下所示:

-module(mod_test).

-export([compile_and_load_mod/0]).

compile_and_load_mod() ->
    compile:file(mod),
    mod:start().

然后您可以调用
mod\u test:compile\u和\u load\u mod()

返回什么
compile:file(mod),
?您所说的“它没有完成任务”是什么意思?它的行为是否不正确?你收到错误消息了吗?@legoscia-实际上是它的编译&只有在以前没有编译的情况下才运行它。当然,我只是简化了它