jadahl / mod_restful

RESTful interface to ejabberd
84 stars 34 forks source link

Failing to compile #10

Open elado opened 11 years ago

elado commented 11 years ago

(New at this so I might be doing something wrong)

Installed erlang on my mac (w/ brew), downloaded the ejabberd source from github and put it at the same level of mod_restful.

Under mod_restful dir, I typed "make" to run the Makefile, and got this:

$  make
erlc -pa ./ebin -I ./include -I ../ejabberd/src -pa ../ejabberd/src -o ./ebin src/gen_restful_api.erl
src/gen_restful_api.erl:76: variable 'Host' is unbound
src/gen_restful_api.erl:76: variable 'User' is unbound
src/gen_restful_api.erl:76: record jid undefined
make: *** [ebin/gen_restful_api.beam] Error 1

all paths seem valid.

What am I doing wrong? Is it possible to just put the .beam file and activate the mod in the .cfg or does it require more?

jadahl commented 11 years ago

Could it be that you are using the master branch? You need to use one of the 2.1.x versions or the 2.1.x branch. At least that's the only one I've tested with.

elado commented 11 years ago

Yes, that worked, thanks!

I'm having another problem with configuration:

  1. I took the ebin/*.beam files into ejabberd-2.1.11/lib/ejabberd-2.1.11/ebin folder.
  2. Put this under listen:
  {{8088, {127, 0, 0, 1}}, ejabberd_http,
   [{request_handlers, [{["api"], mod_restful}]}]}

and this under modules:

   {mod_restful, [
    {api,
     [
      {["admin"], mod_restful_admin, [
       {key, "secret"},
       {allowed_commands, [register, unregister]}
      ]},
      {["register"], mod_restful_register, [{key, "secret"}]}
     ]}
   ]}

and ran

✗ ./ejabberdctl live

and got

Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:8:8] [rq:8] [async-threads:0] [hipe] [kernel-poll:true]

Eshell V5.8.5  (abort with ^G)
(ejabberd@localhost)1> 
=ERROR REPORT==== 27-Oct-2012::11:34:56 ===
Loading of /usr/local/ejabberd-2.1.11/lib/ejabberd-2.1.11/ebin/mod_restful.beam failed: badfile

=ERROR REPORT==== 27-Oct-2012::11:34:56 ===
beam/beam_load.c(1365): Error loading module mod_restful:
  use of opcode 153; this emulator supports only up to 152

=ERROR REPORT==== 27-Oct-2012::11:34:56 ===
C(<0.41.0>:gen_mod:75) : Problem starting the module mod_restful for host "jabber.local" 
 options: [{api,[{["admin"],
                  mod_restful_admin,
                  [{key,"secret"},{allowed_commands,[register,unregister]}]},
                 {["register"],mod_restful_register,[{key,"secret"}]}]}]
 error: undef

=ERROR REPORT==== 27-Oct-2012::11:34:56 ===
C(<0.41.0>:gen_mod:80) : ejabberd initialization was aborted because a module start failed.

Crash dump was written to: /usr/local/ejabberd-2.1.11/logs/erl_crash_20121027-113455.dump
Problem starting the module mod_restful for host "jabber.local" 
 options: [{api,[{["admin"],
                  mod_restful_admin,
                  [{key,"secret"},{allowed_commands,[register,unregi

What am I missing? How should the {api, [APISpec]} look on the cfg file?

Thanks!

jadahl commented 11 years ago

It looks like you are building mod_restful with compiler from a newer version of OTP than you load ejabberd with:

=ERROR REPORT==== 27-Oct-2012::11:34:56 ===
beam/beam_load.c(1365): Error loading module mod_restful:
use of opcode 153; this emulator supports only up to 152