[asterisk-dev] Compiling Module outside of source tree

Steve Murphy murf at digium.com
Wed Sep 10 18:50:00 CDT 2008


On Wed, 2008-09-10 at 16:39 -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
> 
> Can anyone offer any advice?
> 
> Joe

Joe--

I appreciate your energy and willingness to try it "your way", but
really,
save yourself some time and agony, and just plop your cdr_mysql.c file
in
the cdr dir.

If you really, really, must have it standalone, then don't forget to
include
the source tree's include/asterisk  dir in your -I path.

Copy the other modules' structure, to make sure you include the right 
headers, etc., and you should be able to make a loadable module.

murf

-- 
Steve Murphy
Software Developer
Digium
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3227 bytes
Desc: not available
Url : http://lists.digium.com/pipermail/asterisk-dev/attachments/20080910/6bca35bd/attachment.bin 


More information about the asterisk-dev mailing list