----- Original Message -----
From: "Erik Hollensbe" <[EMAIL PROTECTED]>
To: <inline@perl.org>
Sent: Wednesday, June 18, 2008 2:15 AM
Subject: AutoLoader issues with Inline::CPP
Greetings folks...
I'm having a problem with an Inline::CPP module I'm writing. It seems that
it's trying to local an autosplit routine in the _Inline dir that doesn't
exist after Inline does its initial magic.
Here's the actual error:
Can't locate auto/MIME/KDE/version.al in @INC (@INC
contains: /home/erikh/git/mime-kde/_Inline/lib
I can reproduce the behaviour with:
---------------------------------------------
package MIME::KDE;
use warnings;
use Inline CPP => <<'EOC';
#include <iostream>
namespace MIME {
namespace KDE {
const char* version(void) {
return "my version is 0.01";
}
}
}
EOC
$z = MIME::KDE::version();
print $z, "\n";
----------------------------------------
Normally, for a package named MIME::KDE, the shared object would be
/auto/MIME/KDE/KDE.so, and the version() function would be found. But in
this instance, the shared object that Inline::CPP builds is
auto/MIME/KDE_xxxx/KDE_xxxx.so (where xxxx are hex digits).
If I'm on the right track you should have:
/home/erikh/git/mime-kde/_Inline/lib/auto/MIME/KDE_xxxx/KDE_xxxx.so.
I think this is the root of the problem.
The "AUTOLOAD" and "version.al" references are a red herring. The last thing
perl does in its attempt to find the missing version function is to look for
version.al - which it then reports as missing (as it doesn't exist). But the
fact that version.al doesn't exist has nothing to do with the problem. (It
*shouldn't* exist ... the real problem is that the version function can't be
found.)
Did you actually install the module in the usual way ? (ie 'perl
Makefile.PL', 'make install'.)
There's a demo module called Math::Simple shipped with the Inline-0.44
source. It works fine when installed by running 'perl Makefile.PL', 'make
test' and 'make install' - you'll find the Math::Simple source in
Inline-0.44modules/Math/Simple folder. Perhaps you just need to emulate what
is being done there in order to get things to work. (Or perhaps there are
some Inline::CPP specific things in relation to the use of 'namespace' that
compilcate the matter .... I don't know, but the more I think about it, the
more likely this seems.)
Another option that should work is to use InlineX::CPP2XS to convert your
Inline::CPP code to a normal XS-type distro (and remove the Inline
dependency altogether).
Just rename mimelib.cpp to KDE.cpp, cd to the directory that is one level up
from src/KDE.cpp, create an empty directory (eg ./build) and run:
perl -MInlineX::CPP2XS -e
'InlineX::CPP2XS::cpp2xs("MIME::KDE","MIME::KDE","./build")'
That should give you a valid XS file (and a typemap, I think). It's then
just a matter of creating a valid ./build/Makefile.PL and ./build/KDE.pm
(and whatever other files you want in ./build- a test script for 'make test'
to work with would be a good idea). Then cd to ./build and build as a normal
perl extension with no Inline dependency.
InlineX::CPP2XS can also write a Makefile.PL and skeleton KDE.pm for you if
you want (and this is what I would be doing if it were my choice):
perl -MInlineX::CPP2XS -e
'InlineX::CPP2XS::cpp2xs("MIME::KDE","MIME::KDE","./build",
{WRITE_MAKEFILE_PL => 1, WRITE_PM => 1, VERSION => "0.01"})'
(I wrote both InlineX::C2XS and InlineX::CPP2XS, but I don't use the CPP
one. I *think* it will give good milage, but it hasn't had a lot of use
....)
See how you get on.
Feel free to enquire further re any problems with any of that.
Oh ... I should add that I'm not an expert on any of this stuff (especially
C++) .... my diagnosis of the problem might be lacking some insight .... and
there may well be other simpler solutions, faik. I hope there's something
here that helps.
Cheers,
Rob