Using Haskell code in VBA (MS Access)? - Garbage Collecting doesn't
work in Haskell DLL?!
Thu, 26 Oct 2000 20:21:59 +0100
After adjusting the call of startupHaskell() in dllMain.c to "startupHaskell(1,args,NULL);" (new 3rd argument), the adder example works fine also with GHC 4.08.1.
But I recognized another problem: The Garbage Colletion seems not to work at all when calling functions in a DLL build with GHC:
When calling some more complex Haskell functions, the execution crashes after calling it the 2nd or 3rd time. Another even "bigger" function, that works fine in an EXEcutable, crashes
even while its first execution in the DLL. (In the first case, calling shutdownHaskell() at the end of the function execution helped, but this can't be the right solution, I think. -
What about memory sizes of a DLL? May it help to increase e.g. the heap size, and how to do this?)
What can I do about this?
> I tried to compile this small example with ghc-4.08.1, but it didn't work (compiling ok., but DLL does not run), while with ghc-4.05 everything is okay. What can be wrong with this?
> Christian Lescher
> > -----Urspr> üngliche Nachricht-----
> > Von: Sigbjorn Finne [SMTP:email@example.com]
> > Gesendet am: Donnerstag, 17. August 2000 20:18
> > An: 'Christian Lescher'
> > Cc: firstname.lastname@example.org
> > Betreff: RE: Using Haskell code in VBA (MS Access)?
> > The support libraries for HaskellDirect provide
> > functions for converting between BSTRs and Haskell'
> > String (Com.marshallBSTR, Com.unmarshallBSTR) --
> > http://www.dcs.gla.ac.uk/fp/software/hdirect/user-32.html
> > has the overview. However, the binaries available for
> > that library is for ghc-4.045, so you'd have to compile
> > them up yourself for ghc-4.08.
> > To build a 'static' DLL, here's what you need to do:
> > - compile up all your Haskell code using -static.
> > - write a .def file containing the entry points you
> > want to expose. In my example, the .def file would
> > just contain:
> > EXPORTS
> > adder@8
> > - link the static DLL:
> > ghc-4.05 -static --mk-dll -optdll--def=adder.def \
> > -o adder.dll adder.o dllMain.o -lHSrts
> > I heard some rumours that -static might disappear. If that's
> > the case, I think that would be unfortunate.
> > --sigbjorn
> > Christian Lescher <email@example.com> writes:
> > >
> > > Thank you for your detailed answer - it's really great, it works! :-)
> > >
> > > However, I have got one more problem: the function I want to
> > > call from VBA is of
> > > type String -> String -> String
> > > Is there a (simple) method to convert VBA strings (BSTR) to
> > > Haskell's [Char] and
> > > vice versa?
> > >
> > > By the way: Is it possible to build DLLs that do not depend
> > > on GHC's runtime DLLs?
> > > I tried out the "-static" option like for compiling EXEs, but
> > > it didn't work.
> > >
> > > CL