[asterisk-dev] Compiling Module outside of source tree

Tilghman Lesher tilghman at mail.jeffandtilghman.com
Wed Sep 10 20:42:30 CDT 2008


On Wednesday 10 September 2008 17:39:22 Joe Lewis wrote:
> 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
>
> Can anyone offer any advice?

You may want to look at the Makefile I've created in one of my
svncommunity repositories:

http://svncommunity.digium.com/view/tilghman/branches/1.4/

-- 
Tilghman



More information about the asterisk-dev mailing list