Re: Problem exporting Haskell to C via a DLL in GHC 6.6

2007-02-08 Thread Brian Hulley
Simon Peyton-Jones wrote: I don't think there is any reason in principle why GHC can't generate DLLs that "just work", but plainly it's deficient at the moment. The fundamental reason is that the DLL mechanism itself doesn't allow initialization/ shutdown do be hidden from the user of a DLL, b

Re: Problem exporting Haskell to C via a DLL in GHC 6.6

2007-02-07 Thread Simon Marlow
SevenThunders wrote: Another question I have is, is it possible to create a statically linked Haskell library that can be linked using MS VC tools? Also I must say I am a bit confused about the use of the routine __stginit_Bad. Suppose I had multiple Haskell modules each with their own functio

RE: Problem exporting Haskell to C via a DLL in GHC 6.6

2007-02-07 Thread Simon Peyton-Jones
Brian, Matt | In the final analysis this seems to work fairly well. I export an End() | function to Matlab that calls | shutdownHaskell(). I then create a Matlab script that calls End() prior to | clearing the DLL out of the namespace. | Since it appears that shutdownHaskell() can be called agai

Re: Problem exporting Haskell to C via a DLL in GHC 6.6

2007-02-06 Thread SevenThunders
ember to use the Matlab script as needed. Meanwhile, it also appears I can call the same routines from inside C, letting windows do the DLL linkage, provided that shutdownHaskell() is NOT called when the DLL unloads as you indicated earlier. Thanks again for the help. -- V

Re: Problem exporting Haskell to C via a DLL in GHC 6.6

2007-02-06 Thread Brian Hulley
SevenThunders wrote: Brian Hulley wrote: SevenThunders wrote: DllMain if (reason == DLL_PROCESS_DETACH) { shutdownHaskell(); return TRUE; } The above *may* be the problem: it is unsafe to do anything in DllMain that... Instead of trying to start/shutdown Haskell from DllMain,

Re: Problem exporting Haskell to C via a DLL in GHC 6.6

2007-02-06 Thread SevenThunders
l function in some form for use in Matlab, or perhaps I should go with the Begin() and End() approach suggested earlier. I'll have to give this some thought since I use my library both inside and outside the Matlab environment. -- View this message in context: http://www.nabble.com/Problem-expo

Re: Problem exporting Haskell to C via a DLL in GHC 6.6

2007-02-06 Thread SevenThunders
library; or both? Another question I have is, is it possible to create a statically linked Haskell library that can be linked using MS VC tools? Also I must say I am a bit confused about the use of the routine __stginit_Bad. Suppose I had multiple Haskell modules each with their own funct

Re: Problem exporting Haskell to C via a DLL in GHC 6.6

2007-02-06 Thread Simon Marlow
SevenThunders wrote: Before I post this as a bug, I thought I'd check to make sure I'm not doing something wrong. For this test case, on my windows XP machine I create a simple Haskell routine that counts the characters in a file, create a DLL for that routine and call it from C. The C code give

Re: Problem exporting Haskell to C via a DLL in GHC 6.6

2007-02-06 Thread Brian Hulley
SevenThunders wrote: Before I post this as a bug, I thought I'd check to make sure I'm not doing something wrong. BOOL STDCALL DllMain ( HANDLE hModule , DWORD reason , void* reserved ) { if (reason == DLL_PROCESS_ATTACH) { /* By now, the RTS DLL should have been hoisted in, but we

Problem exporting Haskell to C via a DLL in GHC 6.6

2007-02-05 Thread SevenThunders
n obvious problem with my code I'd love to be informed about this. -- View this message in context: http://www.nabble.com/Problem-exporting-Haskell-to-C-via-a-DLL-in-GHC-6.6-tf3179123.html#a8821647 Sent from the Haskell - Glasgow-haskell-users mailing list archive at Nabble.com. ___