Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Calling dll function(created in VC++) from Perl

by isha (Sexton)
on Apr 21, 2008 at 04:49 UTC ( [id://681866]=perlquestion: print w/replies, xml ) Need Help??

isha has asked for the wisdom of the Perl Monks concerning the following question:

I have a dll build in VC++. Now, I want to call the functions inside this dll from Perl. How can i do this?! I tried to do this with Win32::API but didn't success. Can anyone tell me how can i achieve this ?
  • Comment on Calling dll function(created in VC++) from Perl

Replies are listed 'Best First'.
Re: Calling dll function(created in VC++) from Perl
by BrowserUk (Patriarch) on Apr 21, 2008 at 04:58 UTC
    I have a dll build in VC++.

    C code, or C++? The name mangling that C++ does makes things harder.

    I tried to do this with Win32::API but didn't success.

    Show us the code!

    Win32::APi can call functions in dlls--it is its sole purpose in being. So, either you did some thing wrong, or ...?

    Without seeing what you tried, guessing is useless.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Calling dll function(created in VC++) from Perl
by tachyon-II (Chaplain) on Apr 21, 2008 at 05:01 UTC

    You need some wrapper code to get at your functions. XS perlxs perlxstut is one way to do it. You may find Inline::C and Inline::CPP easier to work with to start. A quick way to get started is to examine some of the Win32 modules on CPAN and look at how they are doing it. Two C XS examples I did a few years ago are Geo::Coordinates::VandH::XS and Digest::JHash. I only mention these because they are short and relatively trivial so pretty easy to grok at a glance.

Re: Calling dll function(created in VC++) from Perl
by ikegami (Patriarch) on Apr 21, 2008 at 05:05 UTC

    Your DLL function needs to be compiled with the WINAPI calling convention (_cdecl?). I don't care to guess as to what other mistakes you could have made. Perhaps you should show us what you tried.

    Alternatively, you could write an XS interface to it or use Inline::C.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2024-04-26 03:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found