0
votes

Compiled and installed ejabberd version 15.10 on ubuntu 14.04 machine in /opt/ejabberd directory.

In the older version the module can be compiled directly with erlc command and then pasted to ejabberd module dir(or symbolic linked) which was very efficent way to develop the modules.

But after upgrading to newer ejabberd version when using the INFO_MSG()/2 from logger.hrl the ejabberd fails to load the module.

When compiled by placing the module file inside the ejabberd src directory and running make in ejabberd directory as suggested at https://www.ejabberd.im/ejabberd-13.10 and ejabberd how to compile new module the module works.

But this is very inefficient compared to the older method of compiling and running the modules with elrc command directly.

Is the latter approach the right method, if so why was it changed and where are the official docs that explain compiling with latter approach.

2
What is "inefficient" about the way you don't like?Nathaniel Waisbrot
It takes about 9 seconds with the make command. When using the former approach which involves using the erlc command on the single module file it is much faster like about 3 seconds.Talespin_Kit

2 Answers

0
votes

you can compile ejabberd module like this

erlc -I /lib/ejabberd/include -o /lib/ejabberd/ebin   /home/sunil/Documents/ejabberd_custom_modules/mod_profile.erl

In this example /lib/ejabberd/include is header file (.hrl) path , /lib/ejabberd/ebin* is binary file path of ejabberd and '/home/sunil/Documents/ejabberd_custom_modules/mod_profile.erl is source file path.

0
votes

Right way to compile your custom ejabberd module (suggested by process-one) is :-

  • put your module into ejabberd/src folder.
  • come to ejabberd directory in terminal and run command $ sudo make

it will show you that your module is compiled. You can check ebin directory for .beam file that is result of your compilation.

Now to run your module

$ sudo make install

Add your module into config file at /etc/ejabberd/ejabberd.yml restart your ejabberd and your custom module will be running.

Another way of compiling with erlang shell is :- start your erlang to load all included files required by ejabberd module from ebin directory.

> erl -pa <your path to ejabberd/ebin>

You can also give multiple paths separated by space if you are including files from multiple places. Like

> erl -pa <path1/ebin> <path2/ebin>

This will start erlang shell. Next things you need to do are :- do

> cd("<path to your module.erl file>").

compile your module

> c(your module).

Your module.beam file will be generated as a result of your compilation.