[asterisk-dev] Module to Asterisk function Compiler Issue question

Kevin P. Fleming kpfleming at digium.com
Sat Jul 30 18:02:37 CDT 2011


On 07/30/2011 01:53 PM, Mike Myhre wrote:
> I am having problems getting a module I am creating to link to a
> function I created in a patch to my version of asterisk.
> I have declared the function in channels/chan_sip.c as:
>
> typedef void (*sip_reg_tracker_func)(const char *peer, struct
> sockaddr_in *sin, int success, const char *reason);
> int ast_register_sipregtracker(sip_reg_tracker_func)
> attribute_warn_unused_result;
> int ast_unregister_sipregtracker(sip_reg_tracker_func)
> attribute_warn_unused_result;
>
> When I compile it and do a objdump on it, I get:
> 00018070 g DF .text 000000d1 Base ast_register_sipregtracker
> 00018150 g DF .text 000000b6 Base ast_unregister_sipregtracker
>
> I see that it is in the .text section, not the *UND* section. Since it
> isn't a static function, I think this is expected.
>
> When I try to call this function from a module I am creating, I get this
> output from the objdump:
> 00000000 D *UND* 00000000 ast_register_sipregtracker
> 00000000 D *UND* 00000000 ast_unregister_sipregtracker
>
> I think this is why when I try to load my module and it executes the
> function, I get the error:
> undefined symbol: ast_register_sipregtracker
>
> Where am I going wrong? I see other examples of the same declarations of
> other module to asterisk calls that match mine and they appear to all be
> in the *UND* section.

By default, functions are not exported from Asterisk modules other than 
res_* modules. There are two factors controlling this: the flags in the 
AST_MODULE_INFO macro call at the end of the module source file, and the 
'.exports' file for the module in question. In order to export symbols 
from a module, you'll need to modify these areas to be similar to the 
way that res_* modules are configured.

-- 
Kevin P. Fleming
Digium, Inc. | Director of Software Technologies
Jabber: kfleming at digium.com | SIP: kpfleming at digium.com | Skype: kpfleming
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at www.digium.com & www.asterisk.org



More information about the asterisk-dev mailing list