-
Notifications
You must be signed in to change notification settings - Fork 29
Cross compiling OCaml Code to Windows
All of this is based on the instructions and infrastructure of the ocaml-cross project.
sudo apt-get install gcc-mingw-w64-x86-64 libffi-dev libgmp-dev libsqlite3-dev gawk
If you have a working opam/ocaml setup, run opam switch 4.04.0
, otherwise
initialize opam by running opam init --comp=4.04.0
. Don't forget to restart
your terminal or to run eval `opam config env`
afterward.
opam repository add everest-windows git://github.com/wintersteiger/opam-cross-windows#everest-win-pkgs
(This is fork of opam-cross-windows with additional packages required by Everest.)
These packages contain fixes that are not available in the official opam repository yet, so we need to pin them to development repositories. (Check opam-cross-windows for updates on this.)
opam pin add ocamlbuild https://github.com/ocaml/ocamlbuild.git
opam pin add topkg https://github.com/whitequark/topkg.git
At the time of writing, these are the packages that are required by Everest.
opam install -y ocamlfind depext ppx_deriving ppx_deriving_yojson zarith pprint wasm process fileutils stdint batteries sqlite3 menhir fix sedlex ctypes ulex visitors
The following are the same packages as the native ones with -windows
added onto their
names. They contain Windows native code object files/libraries; ocaml-windows
is the base system.
opam install -y ocaml-windows ocamlfind-windows zarith-windows pprint-windows wasm-windows process-windows fileutils-windows stdint-windows batteries-windows sqlite3-windows menhir-windows fix-windows ctypes-windows ulex-windows yojson-windows sedlex-windows ppx_deriving-windows ppx_deriving_yojson-windows visitors-windows
In your FStar directory, compile the snapshot with the ocamlfind toolchain set
to windows
:
FSTAR_OCAMLBUILD_EXTRAS="-toolchain windows" make -C src/ocaml-output
This will produce bin/fstar.exe
which should be a proper Windows binary and
file bin/fstar.exe
should report
bin/fstar.exe: PE32+ executable (console) x86-64, for MS Windows
And, obviously, it should run and work.
- This has been tested only in WSL/Bash on Windows, which can run Windows binaries natively, thus being able to compile & run binaries required during building of packages. On a free-standing Linux, this may require some further changes to some of the package installation scripts or, in the worst case, wine.
-
zarith-windows
andsqlite3-windows
use static libraries (libgmp
and thelibsqlite3
amalgamation) to avoid problems with dynamic linking on the host system. This means that those libraries can not be upgraded by replacing DLLs later. - The
jbuilder-windows
package sometimes fails because of concurrency issues when running with -j; just retry.