perlxs

deploying xs module on CPAN


i was looking on different xs cpan modules and they didn't contains the actucal source code of the library they are binding ,

for example on this library https://st.aticpan.org/source/NANIS/Net-Sharktools-0.009/ the xs module :https://st.aticpan.org/source/NANIS/Net-Sharktools-0.009/Sharktools.xs

has "#include "sharktools_core.h" but if i browse the files on metacpan i didn't find this file .

the same issue with this module : https://metacpan.org/pod/Crypt::OpenSSL::RSA the .xs file contains #include to different openssl files but the files aren't on the distribution.

when such xs module installed how it include the header and compile the C files if they arn't part of the distribution?


Solution

  • These distributions expect the libraries to be available on the system they are installing to. So for example for Crypt::OpenSSL::RSA it expects you to have openssl-dev or the equivalent package installed for your system. An option for making a distribution that doesn't require this is to (separately) release an Alien distribution, and the easiest way to do this now is with Alien::Build. An Alien distribution represents either using the existing installed library or installing the library within Perl's library directories, either way it is made available for Perl to use. For example both Alien::OpenSSL and Alien::LibreSSL exist and can be used by distributions that want to make sure a SSL library is available. Your XS distribution would add the Alien distribution as a dependency and then can use the library via that.