----- Original Message ----- From: "Randy Harmon" <[EMAIL PROTECTED]> To: <inline@perl.org> Sent: Tuesday, October 04, 2005 11:53 AM Subject: CPAN package not making with Inline::MakeMaker (Inline::CPP code)
> > Hi, > > I have a CPAN-style package I'm trying to make using the instructions from the Inline perldoc. It includes C++ code (and uses Inline:CPP). The code compiles fine in my test script using Inline directly, but I'd rather distribute it without an Inline dependency. > > It seems to be going pretty well except that `make disttest` doesn't want to compile the accompanying .cpp and .h files (which I added to the MANIFEST to get them included in the package) once they're prepared for packaging. Seems like it's not using the right compiler, because it's giving me trouble with template-looking stuff (see the error messages below). > > Any recommendations? > Not sure of the fine details of how you're going about this - so I built a module (that works independent of Inline) based around the grammar/t/04const.t code (in the Inline::CPP source distro). I've reproduced the files I used below my sig. Hope there's something there that helps - though it's fairly simplistic, and faik, I may have simplified away the very issues that are confronting you :-) To build my cpan-type distro I ran (as usual) 'perl Makefile.PL', 'make test', and 'make install'. First off I ran the following Inline::CPP script (called cpp.pl): ################## use Inline CPP => Config => BUILD_NOISY => 1, CLEAN_AFTER_BUILD => 0; use Inline CPP => <<'END'; class Foo { public: Foo() {} ~Foo() {} const char *data() { return "Hello dolly!\n"; } }; END if(Foo->new->data eq "Hello dolly!\n") {print "ok 1\n"} else {print "not ok 1\n"} ################## Then I went into the _Inline/build/cpp_pl-0b40 directory and grabbed the 'Makefile.PL', the '.xs' file and the '.map' file to use in my cpan-style distro. Some editting of all but the '.map' file was necessary. 'MANIFEST', 'CPP.pm' and test.pl were written by hand. Cheers, Rob ############ MANIFEST ############ Makefile.PL CPP.xs CPP.map CPP.pm test.pl ############ Makefile.PL ############ use ExtUtils::MakeMaker; my %options = %{ { 'TYPEMAPS' => [ 'CPP.map' ], 'NAME' => 'CPP', 'CC' => 'g++', 'VERSION' => '0.01' } }; WriteMakefile(%options); # Remove the Makefile dependency. Causes problems on a few systems. sub MY::makefile { '' } ############ CPP.xs ############ #ifndef bool #include <iostream.h> #endif extern "C" { #include "EXTERN.h" #include "perl.h" #include "XSUB.h" } #ifdef bool #undef bool #include <iostream.h> #endif class Foo { public: Foo() {} ~Foo() {} const char *data() { return "Hello dolly!\n"; } }; MODULE = CPP PACKAGE = CPP::Foo PROTOTYPES: DISABLE Foo * Foo::new() void Foo::DESTROY() char * Foo::data() CODE: RETVAL = const_cast<char *>(THIS->data()); OUTPUT: RETVAL MODULE = CPP PACKAGE = CPP::Foo PROTOTYPES: DISABLE ############ CPP.map ############ TYPEMAP Foo * O_Inline_CPP_Class OUTPUT O_Inline_CPP_Class sv_setref_pv( $arg, CLASS, (void*)$var ); INPUT O_Inline_CPP_Class if (sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG)) { $var = ($type)SvIV((SV*)SvRV( $arg )); } else { warn ( \"${Package}::$func_name() -- $var is not a blessed reference\" ); XSRETURN_UNDEF; } ############ CPP.pm ############ package CPP; use strict; require Exporter; require DynaLoader; @CPP::ISA = qw(Exporter DynaLoader); $CPP::VERSION = '0.01'; bootstrap CPP $CPP::VERSION; 1; ############ test.pl ############ use warnings; use CPP; if(CPP::Foo->new->data eq "Hello dolly!\n") {print "ok 1\n"} else {print "not ok 1\n"}