Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (7)
As of 2024-04-23 13:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found