[erlang-questions] Remote module compilation

Bengt Kleberg <>
Tue May 26 13:23:13 CEST 2009


Greetings,

In the case of remote loading you have some ways of doing it.

1) Do the computers share the same file system (NFS, etc)?
The you could do:
rpc:call( Node2, code, load, [test] ).

2) If not you have to include the beam file as a binary:
{Module, Binary, Filename} = get_object_code(Module),
rpc:call( Node2, load_binary, [Module, Filename, Binary] ).

See the manual page for the code module
(http://www.erlang.org/doc/man/code.html).


bengt

On Tue, 2009-05-26 at 13:59 +0300, Alin Popa wrote:
> Hi,
> 
> It is possible to send remote a module source and that one to be
> compiled there ? 
> Or, I have a compiled module but is not loaded on the remote process;
> is it possible to send it there, or I should express load it on the
> remote process?
> This is my test module:
> 
> -module(test).
> -export([test_fun/0]).
> 
> test_fun() ->
>    io:format("Hello ~p~n",["World"]).
> 
> 
> now, start one erlang process(on 1st machine):
> 
> erl -name  -setcookie test123
> 
> ... start other erlang process (on 2nd machine):
> erl -name  -setcookie test123
> 
> In 1st node:
> 
> 1> c(test).
> {ok, test}
> 2> 
> 
> In 2nd node, do nothing...
> 
> In the 1st node:
> 
> 2> spawn('', test, test_fun, []).
> 
> Error in process <0.49.0> on node '' with exit value:
> {undef,[{test,test_fun,[]}]}
> 
> (Which is normal, I think)
> 
> 
> So, somewhere in this flow, something like remote module loading can
> be done ?
> 
> Thanks.
> 
> -- 
> Regards,
> 
> Alin
> 
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list