[erlang-questions] Sharing code between modules with emacs

Adam Lindberg adam@REDACTED
Thu Feb 15 13:18:48 CET 2007

Hi Sébastien,

You need to load all modules that your program needs, so if for
example your client needs the \share\src\lib.erl module, you should
load it with:

nonode@REDACTED> l(lib).

Assuming you have \share\ebin\ in your path (by calling
code:add_patha("\mypath\ebin") and of course assuming you have them
compiled to the ebin directory. :-)
After that it's only to call lib:function() in your client or server.
This will work once the lib module is loaded.

To make them compile to the ebin directory, us a make file for
example. Make a file called Emakefile in the \src directory containing

{'*', [{outdir, "../ebin"}, % Where to place the beams. Star means all
.erl files.
       {i, "../include"}, % What directories to include
       {i,"../../share/include"}, % Example include of another application.
       debug_info, strict_record_tests, netload]}. % Stuff that could
be good to have.

Then you can run erl -make in the src directory to compile everything.
You should look into making client, server and share into applications
making it easier for you to start them and load the modules.


On 2/15/07, Sébastien Saint-Sevin <seb-cl-mailist@REDACTED> wrote:
> Hi list,
> I'm new to erlang and have a question regarding the correct way of sharing code between 2 modules.
> I'm writing a client-server app that speaks a common protocol. So i want the shared code to be put in its
> own directory to be accessible to both the client and the server.
> My directories are something like
>         \client\src
>         \server\src
>         \share\src
> But when I compile the client or server source files under emacs, it do not find the code that is put in share.
> How can I do that?
> I understand that if I put the modules under erl-xxx\lib, they will be found automatically by the code loader, but
> I don't want to develop there.
> A second question : how can I make the emacs shell to compile the files in the ebin directory instead of the src one ?
> And have it looking for the .hrl in the include directory ?
> Is this directory structure only for deployment, or can it be used as well while developping with emacs, thus keeping a nicer
> directory structure ?
> TIA,
> Sebastien.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

Adam Lindberg
Mobile: +46734228920

More information about the erlang-questions mailing list