![]() |
|
P is for Practical | |
PerlMonks |
Re: XS from XS?by creamygoodness (Curate) |
on Apr 10, 2010 at 14:40 UTC ( #834004=note: print w/replies, xml ) | Need Help?? |
I know of two ways to do it. First, you can go through the Perl interface using the callback API from perlcall. That would definitely not qualify as "easy", though. Alternatively, you can get the source library to export its C functions somehow. There are numerous ways to accomplish this, some of which are discussed in Dynaloader/XS: sharing C symbols across shared objects. Cross-platform exporting is difficult. I ultimately adopted the technique from Time::HiRes described by salva. Here's code from Snowball.xs which makes 4 symbols from the Snowball stemming library available (sb_stemmer_list, etc):
That works for a small list of functions. It would be cumbersome and impractical for a large export list.
In Section
Seekers of Perl Wisdom
|
|