# How to deploy ocaml programs to windows?

**URL:** <https://discuss.ocaml.org/t/how-to-deploy-ocaml-programs-to-windows/7368>\
**Category:** Learning\
**Created:** [February 26, 2021, 4:13pm UTC](https://discuss.ocaml.org/t/how-to-deploy-ocaml-programs-to-windows/7368 "2021-02-26T16:13:47Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![hbr](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/hbr/32/4813_2.png) [@hbr](https://discuss.ocaml.org/u/hbr)\
**Post date:** [February 26, 2021, 4:13pm UTC](https://discuss.ocaml.org/t/how-to-deploy-ocaml-programs-to-windows/7368/1 "2021-02-26T16:13:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nojb](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nojb/32/519_2.png) [@nojb](https://discuss.ocaml.org/u/nojb)\
**Post date:** [February 26, 2021, 5:21pm UTC](https://discuss.ocaml.org/t/how-to-deploy-ocaml-programs-to-windows/7368/2 "2021-02-26T17:21:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hbr](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/hbr/32/4813_2.png) [@hbr](https://discuss.ocaml.org/u/hbr)\
**Post date:** [February 26, 2021, 5:35pm UTC](https://discuss.ocaml.org/t/how-to-deploy-ocaml-programs-to-windows/7368/3 "2021-02-26T17:35:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nojb](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nojb/32/519_2.png) [@nojb](https://discuss.ocaml.org/u/nojb)\
**Post date:** [February 26, 2021, 5:40pm UTC](https://discuss.ocaml.org/t/how-to-deploy-ocaml-programs-to-windows/7368/4 "2021-02-26T17:40:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![yawaramin](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/yawaramin/32/3384_2.png) [@yawaramin](https://discuss.ocaml.org/u/yawaramin)\
**Post date:** [February 26, 2021, 6:13pm UTC](https://discuss.ocaml.org/t/how-to-deploy-ocaml-programs-to-windows/7368/5 "2021-02-26T18:13:52Z")

</div>

There is this option right now: [GitHub - ocaml-cross/opam-cross-windows: An OCaml cross-toolchain for Windows and several useful libraries](https://github.com/ocaml-cross/opam-cross-windows)

---

<div class="post-metadata">

**Author:** ![nojb](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/nojb/32/519_2.png) [@nojb](https://discuss.ocaml.org/u/nojb)\
**Post date:** [February 26, 2021, 6:42pm UTC](https://discuss.ocaml.org/t/how-to-deploy-ocaml-programs-to-windows/7368/6 "2021-02-26T18:42:59Z")

</div>

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](https://developer.microsoft.com/en-us/windows/downloads/virtual-machines/).

Cheers,  
Nicolas

---

<div class="post-metadata">

**Author:** ![jnavila](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/jnavila/32/527_2.png) [@jnavila](https://discuss.ocaml.org/u/jnavila)\
**Post date:** [February 26, 2021, 9:53pm UTC](https://discuss.ocaml.org/t/how-to-deploy-ocaml-programs-to-windows/7368/7 "2021-02-26T21:53:56Z")

</div>

When in need to distribute binaries for windows of my [application](https://github.com/jnavila/plotkicadsch/releases) I simply resorted to build in Appveyor and get back the artifacts.

---

<div class="post-metadata">

**Author:** ![hbr](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/hbr/32/4813_2.png) [@hbr](https://discuss.ocaml.org/u/hbr)\
**Post date:** [February 26, 2021, 10:16pm UTC](https://discuss.ocaml.org/t/how-to-deploy-ocaml-programs-to-windows/7368/8 "2021-02-26T22:16:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dmbaturin](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dmbaturin/32/2074_2.png) [@dmbaturin](https://discuss.ocaml.org/u/dmbaturin)\
**Post date:** [February 27, 2021, 4:19am UTC](https://discuss.ocaml.org/t/how-to-deploy-ocaml-programs-to-windows/7368/9 "2021-02-27T04:19:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tjammer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/tjammer/32/2915_2.png) [@tjammer](https://discuss.ocaml.org/u/tjammer)\
**Post date:** [February 27, 2021, 12:14pm UTC](https://discuss.ocaml.org/t/how-to-deploy-ocaml-programs-to-windows/7368/10 "2021-02-27T12:14:08Z")

</div>

I’ve been using github actions, namely [setup-ocaml](https://github.com/avsm/setup-ocaml) to build a [small game](https://github.com/tjammer/tacs) on github for windows, linux and macos. Worked as expected out of the box

---

<div class="post-metadata">

**Author:** ![hbr](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/hbr/32/4813_2.png) [@hbr](https://discuss.ocaml.org/u/hbr)\
**Post date:** [February 27, 2021, 1:36pm UTC](https://discuss.ocaml.org/t/how-to-deploy-ocaml-programs-to-windows/7368/11 "2021-02-27T13:36:08Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![tjammer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/tjammer/32/2915_2.png) [@tjammer](https://discuss.ocaml.org/u/tjammer)\
**Post date:** [February 27, 2021, 2:00pm UTC](https://discuss.ocaml.org/t/how-to-deploy-ocaml-programs-to-windows/7368/12 "2021-02-27T14:00:56Z")

</div>

The artifacts can be found on the [Actions tab](https://github.com/tjammer/tacs/actions/runs/578664519)

---

<div class="post-metadata">

**Author:** ![hbr](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/hbr/32/4813_2.png) [@hbr](https://discuss.ocaml.org/u/hbr)\
**Post date:** [February 27, 2021, 4:15pm UTC](https://discuss.ocaml.org/t/how-to-deploy-ocaml-programs-to-windows/7368/13 "2021-02-27T16:15:17Z")

</div>

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_.

---

<div class="post-metadata">

**Author:** ![EduardoRFS](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/eduardorfs/32/2259_2.png) [@EduardoRFS](https://discuss.ocaml.org/u/EduardoRFS)\
**Post date:** [February 27, 2021, 9:55pm UTC](https://discuss.ocaml.org/t/how-to-deploy-ocaml-programs-to-windows/7368/14 "2021-02-27T21:55:17Z")

</div>

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.
