[Olsr-dev] Loading plugin fails, undefined symbol for olsrd functions
Jonathan P. Chapman
(spam-protected)
Wed Mar 24 00:46:25 CET 2010
Hi!
Am 23.03.2010 22:16, schrieb Henning Rogge:
> Sorry, that was in the master branch. In the stable branch you will find an
> example for using dlsym() at line 160+ in the same file.
>
>> around is easier). The easiest way would be to use the pointer to your
>> function as a parameter to set a callback.
>>
I do not want to be overly optimistic since I still get segfaults, but
they seem to be caused by something else (~3000 lines of untested code
;-), so this may well have solved my problem :-)
So this is what I did:
Include the header for dlopen, dlysn
#include <dlfcn.h>
Define a function pointer for each function I use:
void (*create_lq_hello) (struct lq_hello_message *lq_hello, struct
interface *outif) = NULL;
In the LQ Plugins init-function: Create a handler and open the olsrd binary:
void *dynamic_link_handler;
dynamic_link_handler = dlopen ("olsrd", RTLD_NOW);
Then assign the function pointers to the corresponding symbol:
create_lq_hello = dlsym (dynamic_link_handler, "create_lq_hello");
Use the function pointer where appropriate:
(*create_lq_hello) (&my_hello, &some_interface);
Caveat:
I used a static name for the olsrd binary, since argv[0] appears not to
be available to the plugin (neither olsr_argv[0]), a proper version
should determine the actual path of the calling binary and open that.
Any ideas on how to do that are very welcome ;-)
Thanks and best regards!
Jonathan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.olsr.org/pipermail/olsr-dev/attachments/20100324/070c2ab4/attachment.sig>
More information about the Olsr-dev
mailing list