----- Original Message -----
From: "Sankaran P V" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, July 21, 2005 1:18 PM
Subject: How can I call MFC / SDK Functions from Perl
> Hello all,
> Does anybody knows how can I call MFC / SDK calls from Perl?
> I have installed Inline:C module. Is it sufficient? Or any other modules?
I have (in my F:/C folder), the following files:
--- start mfc.h ---
extern "C" __declspec(dllexport) int SomeFunction(int);
----------------------
--- start mfc.cpp ---
#include "mfc.h"
extern "C" __declspec(dllexport) int SomeFunction(int x)
{
return x + 11;
}
--------------------------
I then run:
F:\C> cl /LD mfc.cpp
which gives me 'mfc.lib' and 'mfc.dll'.
I also have the following file (in F:\C):
--- start C_mfc.pl ----
use warnings;
use Inline C => Config =>
LIBS => '-LF:/C -lmfc',
INC => '-IF:/C',
BUILD_NOISY => 1;
use Inline C => <<'EOC';
#include <mfc.h>
int wrap_SomeFunction(int a) {
return SomeFunction(a);
}
EOC
$z = wrap_SomeFunction(1234567);
print $z, "\n";
-------------------------
When I run 'perl C_mfc.pl' I end up with the following errors:
F:/C\mfc.h(1) : error C2059: syntax error : 'string'
C_mfc_pl_5a3b.xs(9) : warning C4013: 'SomeFunction' undefined; assuming
extern returning int
NMAKE : fatal error U1077: 'cl' : return code '0x2'
Stop.
If I change (in C_mfc.pl) both occurrences of 'Inline C' to 'Inline CPP',
then the whole thing builds and runs fine, reporting that $z is 1234578, as
it ought.
Does that answer your question ?
I'm not sure that the dll I built is actually an "MFC" dll. If it's not, can
you provide source code to build a simple "MFC" dll, so that I/we can build
something with which I/we can experiment.
Cheers,
Rob