Compiling a shared (DLL) library with stack

172 views
Skip to first unread message

nect...@gmail.com

unread,
Mar 23, 2017, 7:20:36 AM3/23/17
to haskell-stack
Hello all,

first of all - my thanks to the developers of stack! We use it daily and it has really made a world of difference in Haskell usability. Well done & much appreciated!


LONG VERSION:
I have a commandline Haskell program that now requires a GUI. This should ideally run on Windows as we are controlling equipment that does not have drivers for linux (an automated microscope).

I once wrote a Haskell GUI program using wxHaskell, but found that I ended up with spaghetti code. Perhaps I was doing it all wrong, but I have little desire to repeat that. But at the same time I don't want to duplicate the functionality of the Haskell code.

I was thinking of writing a GUI in C++/Qt, which I know well. Ideally, the C++ code would be limited to the GUI, and I would call into my Haskell code using the FFI. That would be rather painless if I could compile the Haskell code to a DLL callable as if it was a C library. Then it seems as if I could just call hs_init on application startup and hs_exit on shutdown, and everything is set.

I have tried to Google this, but I seem to have found only scattered reports. It's not even clear to me if it is possible at all. But in any case I would very much like to stick with stack!


SHORT VERSION:
Is there a way to easily generate a Haskell DLL from Windows using a stack project? I am really hoping that stack can do the hard work for me, all the way to generating the header file and the dll itself. Would it make a difference if were running this on Linux?

If not, is this on the developer's radar somehow?

Perhaps there is another way to solve this? Suggestions welcome!

Thanks!
Peter

Michael Snoyman

unread,
Mar 26, 2017, 11:13:51 AM3/26/17
to nect...@gmail.com, haskell-stack
I can only speak for myself here, but generating Windows DLLs is simply uncharted waters (whether with or without Stack). I'm not sure if anyone else has given this a shot before either.

--
You received this message because you are subscribed to the Google Groups "haskell-stack" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haskell-stack+unsubscribe@googlegroups.com.
To post to this group, send email to haskel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/haskell-stack/19f83c48-4b2d-4cf7-ae9d-c262b85778d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Neil Mitchell

unread,
Mar 26, 2017, 2:13:02 PM3/26/17
to Michael Snoyman, nect...@gmail.com, haskell-stack
I figured it out and wrote section 13.6.2 of the user manual asof GHC
7.6: https://downloads.haskell.org/~ghc/7.6.1/docs/html/users_guide/win32-dlls.html

No idea if it still works, but no reason to suspect it doesn't.
Certainly it worked robustly at the time.

Thanks, Neil
>> email to haskell-stac...@googlegroups.com.
>> To post to this group, send email to haskel...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/haskell-stack/19f83c48-4b2d-4cf7-ae9d-c262b85778d4%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "haskell-stack" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to haskell-stac...@googlegroups.com.
> To post to this group, send email to haskel...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/haskell-stack/CAKA2JgLBoT6LSSZj9b7nnwvbt1p_mv%3DqHNJfckgt%2BPJZLP7-QA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages