I have a Perl module A
that is a XS based module. I have an A.xs
file, and an aux_A.c
file, where I have some standard C functions. I use DynaLoader
, and it works file.
Now, I have a new module B
, that is also a XS module. I also have the B.xs
file, and the aux_B.c
file. Now, I want that a standard C function defined in aux_B.c
file to be able to use a function defined in aux_A.c
file.
One option is to make A module to create a standard C library, and link B module with it. But I was trying to get away from that option.
Is there any other way to go?
What I am currently getting is DynaLoader complaining on undefined symbol when trying to load the B.so
library.
Thanks Alberto
To make module A export its C symbols with
DynaLoader
, you have to add the following toA.pm
:This is badly documented, unfortunately. See this thread on PerlMonks and the
DynaLoader
source code for more details. The effect of the flag is to setRTLD_GLOBAL
when loadingA.so
withdlopen
which makes its symbols available to other shared objects.