Search code examples
erlangejabberdlager

error while compiling a new custom module in ejabberd


I am trying to compile a custom module and continuously getting this error

`undefined parse transform 'lager_transform'`

I tried almost all the suggestions regarding this error but could not come across anything. I am using ejabberd-18.01 and otp 20


Solution

  • I think you include logger.hrl file. When compiler finds -compile([{parse_transform, lager_transform}]). here it calls lager_transform:parse_transform/2 for making new module. lager_transform gets source code (Erlang AST or Abstract Syntax Tree) and produces new AST which contains some code for generating log information.
    The problem is that your compiler can't find lager_transform.beam for running that function. You can give path of lager to compiler using -pa or -pz flag:

    # I included `logger.hrl`
    $ erlc test.erl
    test.erl: undefined parse transform 'lager_transform'
    
    # Find path of lager's ebin in your system for below command
    $ erlc -pa /opt/ejabberd-18.01/lib/lager-3.2.1/ebin/ test.erl
    # done