Problems using a custom header and c-file

Hey all,

It’s probably a simple to solve problem but I can’t help myself.

The error message I get when executing the code below in chan_sip.c is the following:

symbol lookup error: /usr/lib/asterisk/modules/ undefined symbol: system_get

Do I have to add some kind of dependencies to Asterisk files? I can’t find any information on that.


#include "asterisk/netsock2.h"
void system_get(struct ast_sockaddr *us);


#include "asterisk/system.h"
void system_get(struct ast_sockaddr *us) { … }


#include “asterisk/system.h”


Thank you for any help!


Since you’re making custom modifications to Asterisk, you may want to use the asterisk-dev list for questions about the source code.

It’s also hard to say why you’re running into the error you’re seeing without actually seeing the full source code.

That being said, I’ll take a swing at it.

Translation units have to define what symbols they export. This is typically done in a [module_name] file, which the Asterisk build system consumes to generate the [module_name].exports file consumed during linking. For the main executable, this is main/

If your symbol (system_get) doesn’t match something in its module’s exports file, then it won’t be exported, and external modules who use it won’t be able to find the function when loaded.

You should note that certain symbol “namespaces” are typically always exported. The most important of these are:

  • ast_
  • ao2_
  • stasis_
  • pbx_
  • aco_
  • bridge_

This is why following the nomenclature of a project actually matters - if you had named your function ast_system_get, things would have “just worked”. If you want to make a new naming convention, you’ll need to tell Asterisk to export your public symbols for external modules to consume.

Thanks for your help. It fixed my problem described above. :relieved:

Sorry for warming up this topic again.

How to tell the Asterisk build system to consume to generate system.exports? It apparantly doesn’t do it by itself. The file lies in the same folder as the .c file.