Calling External DLL functions in Perl using Inline



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

.



Relevant Pages

  • Re: need help building DBI.pm 1.48
    ... Future versions of the DBI *will not* support perl 5.6.0 or earlier. ... > mkdir blib/lib ... > Manifying blib/man3/Roadmap.3 ...
    (perl.dbi.users)
  • Re: moving unused of a website
    ... Perl is the language, perl is the binary. ... folder pix_out keeping the same hierarchy as in the original ... mkdir $dir unless -d $dir; ... and make sure to check for errors in subsequent file operations ...
    (comp.lang.perl.misc)
  • Problems installing IO::Tty locally
    ... I need to install locally as I don't have root access, ... install into the main Perl installation, ... mkdir blib/lib ...
    (comp.lang.perl.misc)
  • DBI-1.38 "make test" Details
    ... 11 This is perl, v5.6.0 built for sun4-solaris ... 67 Version 5.006 of perl will NOT BE SUPPORTED by future DBI ... 134 mkdir blib/lib ... 347 Extracted dbiproxy from dbiproxy.PL with variable ...
    (perl.dbi.users)
  • Re: need help building DBI.pm 1.48
    ... > The problem with cmd_head3 is likely because older versions of Perl (the POD ... >> mkdir blib/lib ... >> Extracted dbiproxy from dbiproxy.PL with variable ... >> substitutions. ...
    (perl.dbi.users)