I have a given 32-bit DLL (dds.dll) and a header file (dds.h, C++ style). I do have the source, but I don't want to change it. I'm on Windows using cygwin.
I want to access functions in the DLL through XS, not directly through Perl. I am new to XS.
[I can't figure out how to use Win32::API
. The DLL functions have struct inputs and *struct
inputs (the latter getting modified by the functions), and I can't figure out Win32::API::Struct
. I suppose that would also be one way, but I've given up on that for now.]
I can pass lists of integers between Perl and XS, so that part works. My plan is to pass in a flat list of integers, #include "dll.h"
in the XS code, turn the list into a struct in XS, pass the struct and other arguments to the DLL function, turn the resulting struct into a flat list of integers, and return the list to Perl.
I've reduced XSLoader.pm to the minimum that I need, partly to understand what goes on. It works for my own XS-generated .dll.
I've tried loading dds.dll in the same way, but I think it doesn't make sense, actually. I get past dl_require_symbols
, and dl_undef_symbols()
is OK too. Then dl_find_symbol looks
for some kind of boot symbol and doesn't find it. I imagine that XS creates a bootstrap function which makes the XS functions visible to Perl through dl_install_xsub()
, but normal DLLs don't have this.
In any event, I don't want to make dds.dll functions directly visible in Perl. I want to make dds.dll functions visible to the XS code. It sounds like a simple linking step, but I can't figure it out.
If there's a simpler way, I'm all for it too. Any help appreciated.