Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Calling a C API in a dll from Perl on Windows

by broquaint (Abbot)
on Jun 24, 2002 at 15:32 UTC ( [id://176827]=note: print w/replies, xml ) Need Help??


in reply to Calling a C API in a dll from Perl on Windows

If you're using Inline::C then it's as simple as setting the AUTO_INCLUDE (and optionally INC) parameter and calling the appropriate functions from within the C code.

You could learn up on XS and write your own module, but this route in somewhat trickier.

There's also the handy C::DynaLib module which is specifically designed for interfacing with C libraries from within perl. Here's an example from the module docs

use C::DynaLib; $libc = new C::DynaLib("-lc"); $strncmp = $libc->DeclareSub("strncmp", "i", "p", "p", "I"); $string1 = "foobar"; $string2 = "foolish"; $result = &{$strncmp}($string1, $string2, 3); # $result is 0 $result = &{$strncmp}($string1, $string2, 4); # $result is -1

HTH

_________
broquaint

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://176827]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2025-06-14 14:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.