I can't answer to all your questions at this moment but this commit might be of interest for you: https://github.com/ocaml/opam/commit/f0157ed232ff1100aa049c922b9bdc857ac21998 (see the CLINKING_windows definition which static links everything but the windows APIs) This works with 4.14 but i haven't tried with 5.3 yet so your milage may vary. Regarding OCaml 5.3/mingw64 you shouldn't need to have to do anything with libwinpthreads because it's only used for the msvc port, not the mingw one. Cheers, Kate ________________________________ From: caml-list-request@inria.fr on behalf of Andreas Rossberg Sent: 01 December 2024 17:02 To: caml-list@inria.fr Subject: [Caml-list] Static linking with Mingw and dune 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