Hi,
Are you using gcc compiler or Microsoft compiler ? I’ll assume you’re using an
MS compiler.
As with C, you’ll need a header file that defines the structures of the ‘deal’
and ‘futureTricks’ structs and also defines (prototypes) the SolveBoard
function.
Let’s call that header ‘my.h’ and the dll ‘my.dll’ .
In the Inline::C code, you’d include my.h, and link to my.dll’s import library
(which I’ll call ‘mylib.lib’).
The Inline::C code would also wrap the SolveBoard function.
So your Inline::C code would have something like:
use Inline C => Config =>
BUILD_NOISY => 1,
LIBS => ‘-L/C:/full/path/to/import/library –lmylib’,
INC => ‘-IC:/full/path/to/header’;
use Inline C => <<’EOC’;
#include <my.h>
int wrap_SolveBoard(/* the args you want to pass to wrap_SolveBoard */) {
/* code that sets up the values you need to pass to SolveBoard */
return SolveBoard(/* args */);
}
EOC
If you’re using gcc, you have the option of not needing an import library.
Instead you could replace the LIBS entry in the above Config section with:
MYEXTLIB => ‘C:/full/path/to/my.dll’,
But for MS compilers you need to link to the import lib.
If you don’t have an import lib it can be created from the dll.
Cheers,
Rob
From: [email protected]
I want to use a function such as following. Dll file is available. I would
like to know what I have to do to be able to use any of these functions. (I
will fill in the details of the input needed. What I cannot figure out is what
the header file would be and what other things I need to do within the perl
program so that the DLL is gracefully accessed)
extern "C" __declspec(dllimport) int __stdcall SolveBoard(struct deal, int
target,
int solutions, int mode, struct futureTricks *futp, int threadIndex);
thanks in advance and regards,
Prakash