Static linking with Mingw and dune

Andreas Rossberg <[email protected]> Sun, 1 Dec 2024 18:02:55 +0100
Newsgroups gmane.comp.lang.caml.inria
Message-ID <[email protected]>
I’m banging my head against a very basic problem, namely creating a simple standalone executable on Windows with OCaml 5.2. So here are my, possibly stupid, questions:

- With OCaml 5 on Mingw64, how can I statically link libwinpthreads into an executable (using dune)?

- Some answers I found from a couple of years ago suggested using `-static`, but dune is (nowadays?) running through flexdll for linking, which doesn’t understand that. Is there a substitute?

- Some other answers/discussions mentioned the new `-l:` option being preferable, but I couldn’t find a working example, and all my feeble attempts to use it with dune were unsuccessful.

- What exactly is the difference between dune's `link_flags` and `ocamlopt_flags`, and why do some online answers use the latter for setting linking-related options?

Any help is appreciated.

Thanks,
/Andreas