How do I cross compile a haskell program on a linux machine with a windows (PE) target? How do I cross compile a haskell program on a linux machine with a windows (PE) target? windows windows

How do I cross compile a haskell program on a linux machine with a windows (PE) target?


I tried many possibilities, including GHC on Wine (didn't work for me, despite many notices advertising that it works "out of the box").

For cross compilation, one problem lies in making GHC find your C libraries and DLLs (for windows). Template Haskell will also give you headaches (because it needs to load linux libraries but then compile for windows).

I never managed to get around those problems properly.

In the end, I opted for installing GHC on a Windows VM, and now I use a script to push stuff to a repo, connect to the windows machine via SSH, pull, clean, recompile and test, all executed from a linux CLI and giving me feedback about what's happening on windows.

EDIT: I'm not providing this answer in an attempt to discourage anyone from trying something smarter. I too am interested in real cross-compilation and, if someone has a good solution, I'm all ears. My alternative method always works, but it really is a pain, having to start a VM just for this. Furthermore, it implies using one VM per OS per architecture, which is quite heavy.