Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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
[1nickt]: Corion this looks good, from the pod: "there are 9000+ variations that are detected correctly in the test files (see t/data/* for most of them). If you can think of any that I do not cover, please let me know."
[TCLion]: some moron put the date like this : Mon Feb 20 09:31:30 2017
[Corion]: 1nickt: Yes, the module sounds promising indeed
[1nickt]: "putting the date in correct order" how?
[Corion]: TCLion: Whee ;)
[TCLion]: need to put like this : 2017-02-20 09:30:53
[1nickt]: That's why I asked if you are using DateTime. It has a large number of supporting modules (the author likes the term 'eco-system') so if you are already creating a DateTime obj from your dates, this module would read in the mnoron-formatted 1s seamlessly
[TCLion]: when I put the date together it looks like : 2017-Feb-24 (month is the problem)
[1nickt]: good luck, then.
[TCLion]: looking at DateTime documentation in monastery now

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2017-03-23 14:57 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (288 votes). Check out past polls.