[Perl] Making a Perl interface to C code
Gaal Yahas
gaal at forum2.org
Sun Sep 1 02:46:46 PDT 2002
On Sun, Sep 01, 2002 at 12:22:47PM +0300, Shlomo Yona wrote:
> I the sources to some data structure implemented in ANSI-C.
>
> I would like to make a Perl Module which enables usage of this
> data structure implementation in Perl.
>
> How do I do this?
Look into the Inline module from CPAN and possibly bundled with new
Perls. It's neat:
> I suppose I'll need to make
> 1. A Perl module which supplies the Perl interface
> 2. A Perl module which is the Perl implementation which
> actually talks to the C binaries
> 3. A Makefile (other technologies?) to build the C binaries
> 4. A CPAN package (other technologies?) for easily installing
> the C sources, building the binaries, installing the
> Perl stuff, and so on...
>
> I'd be happy to get some "from scratch" help.
With Inline.pm you'll need to do none of these yourself. You just put
the C source inline in your Perl script, and the module takes care of
compilation (and caching the resultant object for the next time),
(run-time) linking, and binding.
There are some issues--there are always some issues--for example in
packaging this for execution where there's no compiler, or doing the
connections if your C source needs preprocessing. But tell me this isn't
a nice start :-)
--
Gaal Yahas <gaal at forum2.org>
http://www.forum2.org/gaal/
http://www.livejournal.com/~gaal/
More information about the Perl
mailing list