1

I've read that mingw can be used on Linux to build a windows executable from C/C++.

Can other languages do this, and how about popular GUI libraries?

In particular I'm interested in OCaml and Haskell as languages and libSDL, wxWdgets, and GTK as libraries.

fadedbee
  • 42,671
  • 44
  • 178
  • 308
  • If I read the [GHC wiki page on cross compiling](https://ghc.haskell.org/trac/ghc/wiki/Building/CrossCompiling) it should certainly be possible to build Windows executables on Linux when using GHC to compile Haskell programs. – Frerich Raabe Feb 14 '14 at 09:09
  • Regarding OCaml, googling shows there have been some [recent developments](http://caml.inria.fr/mantis/view.php?id=5737), but I don't know the details. Certainly people have been cross compiling in the past, e.g. on [Fedora](http://fedoraproject.org/wiki/Features/Windows_cross_compiler). – lukstafi Feb 14 '14 at 11:26

1 Answers1

3

It doesn't matter whether the language has support - what matters is the compiler (unless you're using a WORA language like Java). To answer your question, it is possible to build a cross compiler on Linux to target the Windows platform. SDL, wxWidgets, and GTK all have Windows versions to my knowledge, but you have to compile them with a compiler targeting Windows to be able to get object code that can run.

Cross compiling is very messy because you need to have one copy of a library of each architecture and platform that you want to target, and they all have to be installed in different places, so you need to play with linker flags a lot.

Here's a blog post explaining how to get a GCC distribution for Linux targeting Windows. And regarding Haskell and OCaml, sadly I'm not knowledgable in these areas, but the general case will hold true.

SevenBits
  • 2,836
  • 1
  • 20
  • 33