How to access hs_free_fun_ptr from a Visual Studio DLL
Brian Hulley
brianh at metamilk.com
Sat Mar 25 10:47:07 EST 2006
Hi -
I have the following declaration and code in part of a DLL I'm writing:
extern "C" {
typedef void (*HsFunPtr)();
extern __declspec(dllimport) void hs_free_fun_ptr(HsFunPtr fp);
}
enum ECallback { ECallback_Render, ECallback_COUNT};
HsFunPtr callback[ECallback_COUNT];
void SetCallback(ECallback c, HsFunPtr fp){
if (callback[c]){
hs_free_fun_ptr(callback[c]);
}
callback[c] = fp;
}
However when I try to build the DLL, I get the following error from Visual
Studio:
Duma.obj : error LNK2019: unresolved external symbol
__imp__hs_free_fun_ptr
So the problem is that the VS is adding __imp__ onto the function name even
though I've specified it as extern "C" and is moreover just ignoring the
dllimport directive and complaining that it can't find the function.
I've also tried deleting the "extern" before the "__declspec" but this
doesn't make any difference. Also, I've tried putting hs_free_fun_ptr into
the IMPORTS section of the def file but this doesn't make any difference
either (I don't even think def files have an IMPORTS section so it's
probably just being ignored).
I've got a horrible feeling that VS will need a .lib file for ghc to allow
it to link against hs_free_fun_ptr but I don't have a clue how to generate
one...
Does anyone know how I can get everything to link?
Thanks, Brian.
More information about the Glasgow-haskell-users
mailing list