How to deploy ocaml programs to windows?

Does anybody know a standard way to deploy programs written in ocaml to windows users. I mean to windows users which don’t have any installation of the ocaml suite or opam.

For Linux or MacOS users it is easy. There are standardized ways to get opam installed and then you just have to issue opam install .... But since opam requires cygwin for windows users, the overhead is significant and might lead windows users who just want the program but not the ocaml suite lead to the decision not to install the program.

As far as I know there isn’t an easy way to distribute programs in source form under Windows. If your target users are not developers, then distributing in binary form seems to be your best bet.

Cheers,
Nicolas

How can you distribute and ocaml program in binary form to windows users if your developing machine is not a windows machine?

I am developing on MacOS. Is there a cross compilation option for ocaml programs? The best would be to use the windows installer.

Regards
Helmut

I believe there are some cross-compilation projects out there, but am not personally familiar with any of them. Perhaps other people in this forum will be able to chime in.

For using a native Windows installer, I don’t think there is anything ready-made, but it is certainly possible to use standard Windows solutions for this (eg NSIS).

Cheers,
Nicolas

There is this option right now: GitHub - ocaml-cross/opam-cross-windows: An OCaml cross-toolchain for Windows and several useful libraries

1 Like

Another option if you don’t want to install Windows on your machine is to use a VM: there are fully working Windows VMs available for development at Download a Windows 10 virtual machine - Windows app development.

Cheers,
Nicolas

When in need to distribute binaries for windows of my application I simply resorted to build in Appveyor and get back the artifacts.

1 Like

Does the same work with GitHub actions and setup-ocaml? That would be a very elegant solution, because GitHub actions are very useful for other purposes as well.

Regards
Helmut

opam-cross-windows works like a charm if the libraries you want are in the repository. The only issue is that the repository is still quite limited, and it needs more people contributing to it. I add new packages and new versions of new packages as I need them and as time allows.

As of building on Windows using a hosted CI, there are going to be minor variations in the build script, but the general approach is the same. I haven’t seen a project using GitHub Actions yet, but for Appveyor and CircleCI there are projects to lift the CI setup from.

I’ve been using github actions, namely setup-ocaml to build a small game on github for windows, linux and macos. Worked as expected out of the box

1 Like

That is interesting. Question: Where do you store your artifacts? You wrote in your workflow:

  - uses: actions/upload-artifact@v2
    with:
      name: tacs ${{ matrix.os }}
      path: |
        _build/default/src/tacs.exe
        _build/default/src/server/server.exe

Where can I find tacs.exe and server.exe for windows?

The artifacts can be found on the Actions tab

1 Like

Sounds great.

Are you sure that the artefacts can be executed. I have downloaded the mac-os artefact, made it executable via chmod u+x tacs.exe and then called it via ./tacs.exe. The operating system refused to start the application with the message cannot verify developer, might be malware.

esy has a nice setup, if you just install it, you can compile on windows by running the cmd as admin, it will install cygwin if required and etc…

Also you can use it on a CI to generate prebuilt assets easily.