[asterisk-dev] Compiling Module outside of source tree
Tzafrir Cohen
tzafrir.cohen at xorcom.com
Thu Sep 11 00:01:18 CDT 2008
On Wed, Sep 10, 2008 at 04:39:22PM -0600, Joe Lewis wrote:
> Hello;
>
> I am new to this list, simply because I have had a question. I want to
> get into module development for asterisk, and I've run into an "issue".
> Hopefully, it should be quick.
>
> For my first task, I thought I'd reinvent the wheel, and create a simple
> MySQL CDR plugin. However, every time I restart asterisk, I get the
> message :
>
> [Sep 10 13:57:55] WARNING[3315]: loader.c:376 load_dynamic_module:
> Module 'cdr_mysql.so' did not register itself during load
> [Sep 10 13:57:55] WARNING[3315]: res_crypto.c:480 crypto_load: Unable to
> open key directory '/usr/share/asterisk/keys'
>
> I haven't even attempted to add the MySQL functionality (almost a "hello
> world"), so I'm starting very basic. I've created a load() function,
> and an unload() function, along with the :
>
> AST_MODULE_INFO (
> "MySQL CDR Log Backend",
> AST_MODFLAG_DEFAULT,
> "MySQL CDR Backend",
> .load = load_module,
> .unload = unload_module,
> .reload = reload,
> );
>
> sitting at the bottom. In the load_module, it starts off with :
>
> static int load_module(void) {
> int res;
> res = 0;
> ast_log(LOG_ERROR,"test: debug message\n");
>
> which leads me to believe that my load_module function isn't being
> called. Truth be told (and I think this is where the culprit is), I
> think it is the way I am compiling my module. Everything I have seen
> states that I should be compiling the module inside of the asterisk
> source tree, but I'd rather just compile it against the binary RPM's (if
> possible). So I ask, is it possible to compile the module outside of
> the source tree? My compilation lines are :
>
> gcc -fPIC -I/usr/include -c cdr_mysql.c -o cdr_mysql.o
> ld -L/usr/lib/mysql/ -shared -lcrypt -lpthread -lmysqlclient -E -rpath
> /usr/lib/mysql/ -o cdr_mysql.so cdr_mysql.o
At first glance you're missing: -DAST_MODULE=\"cdr_mysql\"
-I/usr/inlude is pointless. -rpath should normally go away on sane
systems.
--
Tzafrir Cohen
icq#16849755 jabber:tzafrir.cohen at xorcom.com
+972-50-7952406 mailto:tzafrir.cohen at xorcom.com
http://www.xorcom.com iax:guest at local.xorcom.com/tzafrir
More information about the asterisk-dev
mailing list