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

[MacPerl] Dynaloader, CW and 'shlb' (fwd)



I would like to build a C library using CW, to try interfacing C and
MacPerl:

Re: to Richard Christensen:

> I am very curious how one would do what you are intending to do.

I would like use MacPerl for extract some data writed in special format
(P.E.:_Practical Extraction_), send this datas to a C lib interfacing
with
Perl; the C lib returns result wich are reporting by Perl (R.L.: and
_Report Language_).
I have some C++ classes I want to re-use, and I like better C++ than
Perl, but Perl is _the_ langage for extracting data for a text file.

The dynamic loading "shared library" isn't perhaps the best way for
interfacing C (and C++?) and Perl. Somebody have another idea?

- Another test:

My C code:
int test (int x) {
    return (2*x);
}
is build as a "shared library" in CW IDE 2.0

TestCLib.pm and test.pl are:
  package TestCLib;
  require Exporter;
  require Dynaloader;
  @ISA = qw(DynaLoader Exporter);
  @EXPORT = qw(test);
  bootstrap TestCLib;
  1;
  __END__

  #!/perl -w
  use TestCLib;
  $var = test(5);
  print ">> $var\n";
  __END__

a xs file named TestCLib.xs is in
  #include "EXTERN.h"
  #include "perl.h"
  #include "XSUB.h"

  PROTOTYPES: DISABLE

  MODULE = TestCLib
  PACKAGE = TestCLib

  int
  test(x)
  int x

  CODE:
  return (2*x);


The test.pl execution results in (with the .xs file present or not in
auto folder):
# Can't find 'boot_TestCLib' symbol in Hard Drive:MacPerl
5.1.4b2:lib:MacPPC:auto:TestCLib:TestCLib

File 'Dev:Pseudo'; Line 2
# BEGIN failed--compilation aborted.
File '<AppleEvent>'; Line 2

I tried compiling a 'boot_TestCLib' C function in the 'shlb' project,
but that's change anything.

Does existing some patterns for writing a C lib to interface C and
MacPerl (using CodeWarrior, not MPW)?
Or, somebody know another way (than shlb) to interface C and MacPerl?
My real pb is to use some regexp functions like m//, s///, tr//, split,
and so on.

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch