Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

How to load DLL using

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 module. Code is below:

##!/usr/bin/perl package afSigGen; our $VERSION = '0.01'; require XSLoader; XSLoader::load('afSigGen', $VERSION); 1; ##!/usr/bin/perl use afSigGen;
I tried to load the DLL using 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/ line 191. at line 4. Compilation failed in require at line 1. BEGIN failed--compilation aborted at line 1. I am unable to find the problem for the failure. Please anyone knows please share.

Replies are listed 'Best First'.
Re: How to load DLL using
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.
Re: How to load DLL using
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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1012859]
Approved by marto
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2017-02-21 18:12 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (314 votes). Check out past polls.