Success Story: Cabal and Dlls

Jason Dagit dagit at codersbase.com
Wed Jul 26 19:17:13 EDT 2006


Perhaps I spoke too soon.

I loaded my dll into a C++ application (where it will be used) and as
soon as I hit FreeLibrary() my program crashes.  I tried adding
shutdownHaskell() to the dll and it gets a little better.  It goes
from crashing all the time to crashing some of the time.  I wrote a
small test program in C++ where I added a 100 iteration loop that just
loads and unloads the Dll.  It seems to crash my program usually
before getting to the double digits.  I noticed the memory usage seems
to climb quite a bit too.

I found this thread:
http://www.haskell.org//pipermail/glasgow-haskell-users/2006-March/009771.html

I don't see a solution listed there.  This is a show stopper for me.
If I can't get Dlls working reliably then I won't be using haskell :(
So I'm looking for just about any reasonable solution.

Thanks,
Jason

On 7/26/06, Jason Dagit <dagit at codersbase.com> wrote:
> Ah, when I was looking for information on doing this I didn't think to
> check the Visual Haskell source.  Perhaps I didn't think of it because
> I have yet to get it building (but I think I've found a few things
> that are probably easy to improve, for example, when the .cabal file
> has a syntax error Visual Haskell doesn't report the error correctly).
>
> If you get a chance I would appreciate it if you could look over the
> code I posted on the wiki and try to improve it with your knowledge.
>
> Thanks,
> Jason
>
> On 7/26/06, Krasimir Angelov <kr.angelov at gmail.com> wrote:
> > Hi Jason,
> >
> > I am using the same technique to build VSHaskell itself.
> >
> > Cheers,
> >    Krasimir
> >
> > On 7/27/06, Jason Dagit <dagit at codersbase.com> wrote:
> > > Hello,
> > >
> > > I would like to report that I was able to use Cabal with Visual
> > > Haskell to build Dlls in windows.  I have posted the details about
> > > this on the Haskell wiki (and started an extremely minimal Cabal
> > > page).  If my content is in the wrong place, please feel free to move
> > > it (or edit it or whatever).
> > >
> > > http://www.haskell.org/haskellwiki/Cabal
> > >
> > > The trick was to take the final HSfoo-0.1.o file generated by the
> > > normal build process (and linked with the DllMain.c code) and tell ghc
> > > to build a dll.  I use -package with each of the dependencies in the
> > > cabal file to link with the needed libraries.  The resulting dll seems
> > > to be working.
> > >
> > > This approach is a bit hackish and while I've tried to implement as
> > > much of it as I can in a general way it requires you to hack your
> > > Setup.lhs file if you want to 1) build static 2) specify your exports
> > > 3) specify the name of the resulting dll.  Also, it's only been tested
> > > on my setup which uses Visual Haskell so it may not be fit for general
> > > consumption.  Finally, I just started really looking at Cabal
> > > yestarday so I may not have considered things which an experienced
> > > Cabal user would think about.
> > >
> > > Is it possible to get this functionality built directly into Cabal so
> > > that I tell it I want a DLL built from a library and it knows how to
> > > make it happen?
> > >
> > > Thanks,
> > > Jason
> > > _______________________________________________
> > > Libraries mailing list
> > > Libraries at haskell.org
> > > http://www.haskell.org/mailman/listinfo/libraries
> > >
> >
> >
>


More information about the Libraries mailing list