using C++ for developing freediameter extension

422 views Asked by At

So, I'd like to use C++ for developing freediameter extension, The shared library is compiled and linked successfully, however when it is gonna be used by freediameter daemon, i receive this error:

01/16/17,00:04:59.215241  ERROR  Unable to resolve symbol 'fd_ext_init' for extension /home/usr/Downloads/freeDiameter-master/extensions/ocs_app/ocs_app.fdx: Undefined symbol "fd_ext_init"
01/16/17,00:04:59.215361  ERROR  ERROR: in '((fd_ext_load()))' :        Invalid argument
01/16/17,00:04:59.215377  ERROR  ERROR: in '(fd_core_parseconf(conffile))' :    Invalid argument
01/16/17,00:04:59.215387  FATAL! Initiating freeDiameter shutdown sequence (1)

I guess it has something with name mangling, but i cannot seems to find the solution. already tried to put the entry point into extern block but no luck:

extern "C" {
  static int ta_entry() {
     // C/C++ codes here ..
  }
} 

also when i check "fd_ext_init" definition in the shared libary via nm, it'd be like:

0000000000008140 T _Z11fd_ext_initiiPc
1

There are 1 answers

1
Matt Williams On BEST ANSWER

Good investigation!

Did you have fd_ext_init in your extern "C" block too? All the APIs that freeDiameter wants to resolve by name at runtime need to be in the extern "C" block so that there names are not mangled.

Note that fd_ext_init is defined by the EXTENSION_ENTRY macro, so it's your invocation of that that needs to go in extern "C".

(I wouldn't actually expect ta_entry to need to go in the extern "C" block - I think that this will not need to be resolved by name at runtime.)

I hope that helps!