Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

How to load DLL using XSLoader.pm

by PerlRider (Initiate)
on Jan 11, 2013 at 10:53 UTC ( #1012859=perlquestion: print w/ replies, xml ) Need Help??
PerlRider has asked for the wisdom of the Perl Monks concerning the following question:

Hi All, Struck to load DLL uisng XSLoader.pm module. Code is below:

##!/usr/bin/perl #afSiggen.pm package afSigGen; our $VERSION = '0.01'; require XSLoader; XSLoader::load('afSigGen', $VERSION); 1; ##!/usr/bin/perl #Siggen.pl use afSigGen;
I tried to load the DLL using XSLoader.pm in perl 5.6 and it loaded successfully. But When I try to load the same DLL with Perl 5.16 version, it failed. During loading I got the following popup error message from perl.exe: The application has failed to start because perl56.dll was not found. When I press ok on the popup: Can't load './afSigGen.dll' for module afSigGen: load_file:The specified module could not be found at :/Perl/lib/DynaLoader.pm line 191. at afSigGen.pm line 4. Compilation failed in require at SigGen.pl line 1. BEGIN failed--compilation aborted at SigGen.pl line 1. I am unable to find the problem for the failure. Please anyone knows please share.

Comment on How to load DLL using XSLoader.pm
Download Code
Re: How to load DLL using XSLoader.pm
by Anonymous Monk on Jan 11, 2013 at 11:18 UTC
    You don't use XSLoader to load random dlls, or dlls compiled for one perl version on another perl version, XSLoader is nothing like Win32::API
Re: How to load DLL using XSLoader.pm
by bulk88 (Priest) on Jan 11, 2013 at 12:09 UTC
    If it wasn't compiled with Makefile.PL or Build.PL, you can't use XSLoader on it. XS libraries/DLLs can only be used within the same minor (middle number) version. You can NOT under any circumstance use a XS module compiled with 5.12 on 5.14 or a XS module compiled with 5.14 on 5.12 Perl. Or a 5.12 XS module with a 5.10 or 5.16 Perl. You can use an XS module compiled with Perl 5.12.3 with Perl 5.12.1 at runtime or any other permutation aslong as the first and 2nd numbers match. The last number can change, but Perl guarantees ABI between maintenance releases. XSLoader is not for loading non-XS DLL (although it looks like you have an XS DLL since it is linked to Perl 5.6). If you are crazy, on 32 bit Windows, and want pain, you can use Dynaloader to load non-XS DLLs, without Win32::API, see Pure Perl module(245 lines) that calls external libraries - no XS file..

      can only be used within the same minor (middle number) version.

      most of the time, lots of times even that isn't guaranteed

      Hi, Thanks for your valuable reply... I want to load the C DLL to call couple of C functions from perl. I want to try with XSLoader to load the DLL. I am knew to use this XSLoader. Can you please let me know the sample Makefile.PL to compile it and if any prerequisites.

        read perlxstut. You will have to write C code if you go that route. Perlmonks supports people writing XS code or C code for Perl.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1012859]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (13)
As of 2014-09-18 17:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (120 votes), past polls