[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: FW: [MacPerl]How to access C/C++ routines..



Carlos Velasques wrote:

*****
The C/C++ routines I want to call are available for the Mac, and I wanted
to do the interfacing at home with my mac, however, the API's and the need
to interface will ultimately be done on Unix (Sun Solaris.) If is simpler
on Unix then that is the will be my first approach.

The header files are available and the calls are pretty straightforward
(all are vanilla flavored C routines, no real C++ involved.) All calls
either take a pointer to some long winded structure or return pointers to
long winded structures. One thing that needs to get pointed out: some
structures have UNIONs declared so i am not sure how that gets handled via
Perl.

A friend suggested I look at the DynaLoad module as well. I have no idea
what it is but what I need is stupid simple. Have no desire for anything
complex or something that will take me forever to learn.

*****

I downloaded the header file, and I'll take a gander at it.

The mechanics of using h2xs or SWIG are easier on UNIX, and so is the
actual build, but to be honest the real work resides in choosing your Perl
API. In other words, often a straight translation of everything in the C
headers into equivalent Perl routines is not the way to go.

When you prepare an extension module for Perl, it consists of a shared
library and a Perl module (.pm) file. The .pm file 'uses' Dynaloader to
actually load your shared library. (Well, to be precise, the bootstrap() 
routine from Dynaloader does the work by calling yet another function,
which is written in C and is OS-specific). If you use h2xs or SWIG they
will both prepare skeleton .pm files that put this kind of stuff in for
you.

Arved



===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org