# \[ANN\] Easy cross compilation using esy

**URL:** <https://discuss.ocaml.org/t/ann-easy-cross-compilation-using-esy/6612>\
**Category:** Community\
**Tags:** esy, cross-compilation, opam, dune, announce\
**Created:** [October 15, 2020, 10:38pm UTC](https://discuss.ocaml.org/t/ann-easy-cross-compilation-using-esy/6612 "2020-10-15T22:38:36Z")\
**Posts on this page:** 1\
**Page:** 1

<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:** [October 15, 2020, 10:38pm UTC](https://discuss.ocaml.org/t/ann-easy-cross-compilation-using-esy/6612/1 "2020-10-15T22:38:36Z")

</div>

Hello,

I’ve been working on this for a couple of months now, and now it is ready for an initial announcement of my tools to cross compiling OCaml and ReasonML Native.

> [GitHub - EduardoRFS/reason-mobile](https://github.com/EduardoRFS/reason-mobile)

## What it can do

Out of box it can cross compile most dune and topkg, packages available on opam for a couple of platforms, there is also patches for popular packages.

You can also compile opam packages by making an wrapper, like

> [misc: detect CPU architecture from C compiler by EduardoRFS · Pull Request #84 · mirage/mirage-crypto · GitHub](https://github.com/mirage/mirage-crypto/pull/84/files)

## Limitations

Your package should build with OCaml 4.10, and all the packages that are built for the `host` will also be build for the `target`, so sometimes you need to fix a package that you will not use directly.

Some packages you will need to pin to a `dune-universe` fork version

## How to use it

```sh
## compile your project
esy

## generate the wrapper
esy add -D generate@EduardoRFS/reason-mobile:generate.json
esy generate android.arm64

## build for android.arm64
esy @android.arm64

```

## Platforms

All of the following are tested from Linux and macOS, but I would suppose that FreeBSD should be also working as a build system.

| Targets |
| --- |
| android.arm64 |
| android.x86\_64 |
| ios.arm64 |
| ios.simulator.x86\_64 |
| linux.musl.arm64 |
| linux.musl.x86\_64 |

## What I tested

In the past I was able to build `Revery` the UI framework for `Android` and `iOS`

But recently I did compile `esy` the package manager itself for all of the following platforms above from an `Arch Linux x86_64` and `macOS Catalina x86_64`. Including `iOS`, with the right version of OCaml it will run inside of the new `macOS ARM64` and inside of a jailbroken iPhone.
