monks,

The issues with embedding perl, distibuting perl apps without a perl install, perl runtime environments, perl plugins etc etc are well-covered here at the monastery.

I am not a C programmer and do not enjoy compiling code-bases like Perl, but as a perl coder the idea of embedding is appealing to me. PAR fulfills this to a certain extent, but real easy embedding could do a lot more than just application packaging.

As a proof-of-concept, I took the minimal C i knew and hacked together a surprisingly small .h file that can be used to link up to a precompiled perl library - perl58.dll or libperl.so.
The code in its current state is trivial and limited, but it has been tested on Mandrake 9.1 and Windows and works AOK running a fairly large, pure-perl web-app from the command line.
#include "perlembed.h" int main(int argc, char** argv, char** env) { perlembed_setup("perl58.dll"); perlembed_run(argc, argv, env); perlembed_teardown(); return 0; }
Thats the API as it stands now, effectively miniperlmain.c with cross-platform library loading...

I would appreciate any opinions from the real C coders amongst us on the viability and limits of this approach, and whether this is worth pursuing further. Of course ideas/improvements from anyone are welcome.

edit: removed link to tarball, see below for the basic gist
cheers

In reply to poor mans embedding by Ctrl-z

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.