|P is for Practical|
Better way to force Inline to use compiled binary instead of C source?by vr (Curate)
|on Jun 11, 2022 at 22:57 UTC||Need Help??|
vr has asked for the wisdom of the Perl Monks concerning the following question:
I want to run a script at computer, where I'd rather not expose its (this script's) C guts (embarrassing situation... sorry). Consider SSCCE of myscript.pl:
I know nothing about XS; and (another alternative) though I think I can compile C to a DLL and then use FFI, I suspect it would be less efficient: script is run many times -- as e.g. $^X myscript.pl -- by larger continuously running Perl application. So I'd prefer to stay with Inline::C, but 'hide' the algo realisation.
There's FAQ topic, but it's (1) not exactly about what I need, and thus not achieves what I want, (2) I found it's not exact in what it describes -- no need to split Perl and C into separate files, no need to bother with MD5.
Nevertheless, using FAQ as base and example Math::Simple bundled with Inline:
mkdir MyC, place 2 files there:
then run perl Makefile.PL, gmake test. The blib directory is created, where I can delete everything but 2 files:
the latter I modify as ('END' can be anything, no need to write MD5):
Then I modify original myscript.pl as:
Then move it to some other location for testing, bundled with blib folder (which itself is 4 folders, 2 files). Looks like goal achieved, but I wonder if there is 'more correct' way. In particular, I'd like to avoid creating dummy module and package (myC), or at least have it declared inside myscript.pl itself. 2nd point, I'd like the dll to be placed e.g. into "standard" _Inline directory with "standard" Inline hierarchy and naming conventions, since this folder already exists anyway (for parts which I don't bother to 'hide'. Like I said the whole situation is complicated and embarrassing), so there's no need to use blib;. Maybe there are Inline configuration options for that?