Re: Win32::API cannot load any DLL?




"cyl" <u8526505@xxxxxxxxx> wrote in message news:1176513128.071486.301220@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On 4月11日, 下午2時20分, "Sisyphus" <sisyph...@xxxxxxxxxxxxxxxxx> wrote:

For me, running 'perl msdll.dll' prints out 144 (as expected).


It does not work me. I can compile the dll correctly but Win32::API
just failed to load it. I've decided to try SWIG as my solution. Many
thanks for the help. IMO, there should be room for the implementation
of this dll loading stuff because I can use other script language such
as Ruby to load my dll without any problem. Just wondering if there's
any difficulty for Perl to support such capability (loading cdecl
declared function)?

I hope you tried to run the script as 'perl msdll.pl' not 'perl msdll.dll' (as I wrote :-)

I don't know why you're having trouble with the formulation I provided - it should work fine.
Is the dll in the the path ? (I think it needs to be - unless you provide the fully qualified name.)

Did you build the dll using VC 6 ? (Safest to use the compiler that was used to build perl - which is VC 6 , if you're using ActiveState perl.) I find that I get failures, too, if I try to mix compilers (VC 6 and VC 7 in my case).

Do you get any warnings or error messages with any of the failures ?

Perl has absolutely no difficulty with loading dll's (irrespective of the calling convention used) - it's only the CPAN version of Win32::API that has trouble with cdecl.

As an alternative to accessing the demo dll (that I provided with my last post) using Win32::API, it's quite trivial to access that dll function using Inline::C:

--inline.pl--
use warnings;
use Inline C => Config =>
BUILD_NOISY => 1,
LIBS => '-LC:/path/to/import_lib -lmsdll'; # link to the import lib (msdll.lib)

use Inline C => <<'EOC';

int wrap_dll(int x) {
return dll_int_square(c);
}

EOC

my $num = 12;
print wrap_dll($num);

-- end Inline.pl --

That will work just as well, even if the dll was not built using stdcall. (Again, you may strike trouble if you mix compilers.)

Or you can achieve the same using XS directly.

Or you can use swig :-)

Cheers,
Rob

.



Relevant Pages

  • Re: The procedure entry point Perl_Glockhook_ptr could not be located in the dynamic link library pe
    ... There's no way to resolve this issue short of upgrading the perl version itself? ... The procedure entry point Perl_Glockhook_ptr could not be located in the dynamic link library perl58.dll ... I spent a whole day trying to what caused and found out ActiveState dll had a wrong version DLL in the 5.8.7 distro ... This e-mail communication and any attachments may contain confidential and privileged information for the use of the ...
    (perl.dbi.users)
  • Re: Win32::API cannot load any DLL?
    ... running 'perl msdll.dll' prints out 144. ... I can compile the dll correctly but Win32::API ... of this dll loading stuff because I can use other script language such ... as Ruby to load my dll without any problem. ...
    (comp.lang.perl.misc)
  • DLL Call Follies
    ... my head against the wall trying to get Win32::API interfacing to a dll ... the work space must be at least 32k bytes (bigger won't ... Error codes are listed in the "Return Error Codes" section of this ... Perl is throwing an error dialog "Perl Command Line ...
    (comp.lang.perl.misc)
  • Re: Parsing Google-like queries for FT search
    ... but i didn't find any mention of perl in your question. ... SQL2005 you can declare external stored function using win DLL (this was ... true also on SQL2000) and any CLR language. ... I'm planning of testing this way in the next couple of days, ...
    (microsoft.public.sqlserver.fulltext)
  • Re: Question about creating modules
    ... I'm new to perl and need a little help. ... I've tried creating a module from a C++ source using swig and the ... With ActiveState perl you really should be using 6.0 ... There's a good example of accessing a dll in the Inline::C cookbook ...
    (comp.lang.perl.modules)