Can't really help out with h2xs, and I'm not entirely sure that I understand what you're doing. You say you want "to write a shared C library to be used from Perl", but then you seem to merely want to generate an XS file with a couple of functions in it. Anyway, fwiw, which may not be much:
<plug>
I can generate an XS file, a Makefile.PL and a stub TwinTree.pm using InlineX-C2XS and libtwintree.c.
One caveat - because it's using Inline::C, and because Inline::C doesn't understand 'void' as the argument list, I've had to rewrite libtwintree.c as:
// libtwintree.c:
#include "libtwintree.h"
int return_one() { return 1; }
int return_zero() { return 0; }
That 'void' in the argument list would be, I think, incorrect if included in the XS functions. (It's certainly not needed, anyway.)
Then it's just a matter of running
perl -MInlineX::C2XS="c2xs" -we 'c2xs("TwinTree","TwinTree",{SRC_LOCATION=>"./libtwintree.c",WRITE_MAKEFILE_PL=>1,VERSION=>0.01,WRITE_PM=>1})'and you'll find TwinTree.xs, Makefile.PL and TwinTree.pm all sitting in the cwd:
TwinTree.xs:
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
// libtwintree.c:
#include "libtwintree.h"
int return_one() { return 1; }
int return_zero() { return 0; }
MODULE = TwinTree PACKAGE = TwinTree
PROTOTYPES: DISABLE
int
return_one ()
int
return_zero ()
TwinTree.pm:
package TwinTree;
use strict;
require Exporter;
*import = \&Exporter::import;
require DynaLoader;
$TwinTree::VERSION = '0.01';
DynaLoader::bootstrap TwinTree $TwinTree::VERSION;
@TwinTree::EXPORT = ();
@TwinTree::EXPORT_OK = ();
sub dl_load_flags {0} # Prevent DynaLoader from complaining and croaki
+ng
1;
Makefile.PL:
use ExtUtils::MakeMaker;
my %options = %{
{
'TYPEMAPS' => [],
'NAME' => 'TwinTree',
'INC' => '',
'VERSION' => '0.01'
}
};
WriteMakefile(%options);
# Remove the Makefile dependency. Causes problems on a few systems.
sub MY::makefile { '' }
That's using version 0.14, which has only just been uploaded to CPAN, amd may take a while to reach all mirrors. Version 0.13 is quite functional, but adds the cwd to INC and the standard perl typemaps to TYPEMAP in the Makefile.PL - which neither breaks nor achieves anything (but is a bit annoying).
</plug>
Cheers,
Rob
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.