Calling External DLL functions in Perl using Inline
- From: "Sankaran" <psankarv@xxxxxxxxx>
- Date: 11 Jul 2005 06:47:12 -0700
Hello
I am trying to call a DLL function from Perl using Inline as follows
use Inline C => DATA =>
LIBS => '-lInlinetestLib';
greet();
__END__
__C__
#include "InlinetestLib.h"
void greet(){
int nId = fnInlinetestLib();
printf ("%d", nId);
printf("Hello, world from Perl Inline, By Sankaran\n");}
Where:
InlinetestLib is a test dll with 1 exported function fnInlinetestLib()
I am getting the following error while I am trying to run this;
E:\Sankaran\Work\TP-TAImpacts-LM051049\PerlInline\MyTest1>Perl Hello.Pl
Microsoft (R) Program Maintenance Utility Version 6.00.9782.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.
mkdir blib
mkdir blib\lib
mkdir blib\arch
mkdir blib\arch\auto
mkdir blib\arch\auto\Hello_Pl_74c2
mkdir blib\lib\auto
mkdir blib\lib\auto\Hello_Pl_74c2
D:\Perl\bin\Perl.exe -ID:\Perl\lib -ID:\Perl\lib
D:\Perl\lib\ExtUtils/xs
ubpp -typemap D:\Perl\lib\ExtUtils\typemap Hello_Pl_74c2.xs >
Hello_Pl_74c2.xsc
&& D:\Perl\bin\Perl.exe -ID:\Perl\lib -ID:\Perl\lib
-MExtUtils::Command -e mv H
ello_Pl_74c2.xsc Hello_Pl_74c2.c
cl -c
-IE:/Sankaran/Work/TP-TAImpacts-LM051049/PerlInline/MyTest1 -O1 -M
D -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT
-DPERL_IMPLICIT_CONT
EXT -DPERL_IMPLICIT_SYS -DPERL_MSVCRT_READFIX -O1 -MD -DNDEBUG
-DVERSION=\"
0.00\" -DXS_VERSION=\"0.00\" -ID:\Perl\lib\CORE Hello_Pl_74c2.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for
80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
Hello_Pl_74c2.c
E:/Sankaran/Work/TP-TAImpacts-LM051049/PerlInline/MyTest1\InlinetestLib.h(15)
:
error C2054: expected '(' to follow 'class'
E:/Sankaran/Work/TP-TAImpacts-LM051049/PerlInline/MyTest1\InlinetestLib.h(15)
:
error C2085: 'CInlinetestLib' : not in formal parameter list
E:/Sankaran/Work/TP-TAImpacts-LM051049/PerlInline/MyTest1\InlinetestLib.h(15)
:
error C2143: syntax error : missing ';' before '{'
NMAKE : fatal error U1077: 'cl' : return code '0x2'
Stop.
A problem was encountered while attempting to compile and install your
Inline
C code. The command that failed was:
nmake > out.make 2>&1
The build directory was:
E:\Sankaran\Work\TP-TAImpacts-LM051049\PerlInline\MyTest1\_Inline\build\Hello_Pl
_74c2
To debug the problem, cd to the build directory, and inspect the output
files.
at Hello.Pl line 0
INIT failed--call queue aborted.
But when I am trying a sample which I got from net, it is running fine.
The example which I tried is
use Inline C => DATA =>
LIBS => '-luser32',
PREFIX => 'my_';
MessageBoxA('Inline Message Box', 'Just Another Perl Hacker');
__END__
__C__
#include <windows.h>
int my_MessageBoxA(char* Caption, char* Text) {
return MessageBoxA(0, Text, Caption, 0);
}
This is displaying a MessageBox as the output.
My doubts are;
· Where should be the .h file contains the exported interface?
· Path of LIB file and DLL?
· Is it necessary to provide my DLL / LIB path in the environment
PATH variable? (I have already added the DLL / LIB / .H file path in
the PATH variable)
Kindly provide the guidelines incase if any, so that it will help me.
Regards,
Sankaran
.
- Follow-Ups:
- Re: Calling External DLL functions in Perl using Inline
- From: Sisyphus
- Re: Calling External DLL functions in Perl using Inline
- Prev by Date: Re: Windows: Perl:Inline
- Next by Date: mod_perl2 passing env vars when doing internal_redirects
- Previous by thread: CGI::StringDB Embedding perl data structures in an HTML post.
- Next by thread: Re: Calling External DLL functions in Perl using Inline
- Index(es):
Relevant Pages
|
|