----- Original Message -----
From: "Eric Pernice" <epern...@gmail.com>
To: <inline@perl.org>
Sent: Wednesday, December 23, 2009 6:04 AM
Subject: Static Linking with Inline::C
Hello,
I'm very new to extensions in Perl, and was hoping someone could tell me
how
I can link statically with Inline::C. I have written an application
that's
using the WinHttp API, and am compiling it with PerlApp. The resulting
executable runs fine on my machine, but does not run on any other machine
(An error says "Can't load
'C:\DOCUM~1\ADMINI~1\LOCALS~1\Temp\pdk-Administrator-18032\/auto/WinHttp/API/API.dll'
for module WinHttp::API: load_file:This application has failed to start
because the application configuration is incorrect"...
WinHttp::API is my perl module that uses Inline::C and interfaces with the
WinHttp C API. API.dll is the file found in
_Inline\lib\auto\WinHttp\API\.
I am using DynaLoader to load the API.dll.
Any help would be very much appreciated.
I'm assuming your problem arises because of your extension's dependency upon
Inline::C. (I *do* recall that pp'ing an extension that depends upon
Inline::C was not straightforward. Perhaps that's no longer the case - but
I'd prefer to not have to work through it again :-)
I like to remove the Inline::C dependency from any extensions that I write -
and I wrote InlineX::C2XS to facilitate this.
It would be just a matter of taking the C code (as is) from the Inline::C
section of your current file(s), pasting that code into a file named (eg)
'/home/me/API.c', cd'ing to an *empty* directory, and running the following
script (untested):
#############################
use warnings;
use InlineX::C2XS qw(c2xs);
$version = 1.23; # or whatever
c2xs('WinHttp::API', 'WinHttp::API', {WRITE_MAKEFILE_PL => 1, WRITE_PM => 1,
VERSION => $version, SRC_LOCATION => '/home/me/API.c'});
#############################
That will give you, in the current directory, a "normal" CPAN distribution
that can be built in the usual way - ie 'perl Makefile.PL', 'make test',
'make install'. Obviously, you'll need to copy any existing perl code and
pod documentation from your current API.pm into the API.pm that
InlineX::C2XS autogenerates, and you'll need to make use of your existing
test suite, CHANGES, README, etc. files (as InlineX::C2XS does not write
these for you).
The Inline::C dependency has now been removed - and your left with an
extension that can be treated like any other CPAN extension. There's now
also the option of building a ppm package of the extension (instead of
having to 'pp' it).
If this doesn't help, could you please provide more information on what
you're trying to do - I'm not sure that "static linking" is *really* the
solution you need.
Cheers,
Rob