Skip to content
ytomino edited this page Oct 27, 2020 · 5 revisions

Compile to the 32 bit binaries on the 64 bit OS (and vice versa)

First, setup the multilib-version gcc or clang. (e.g. Do apt install gcc-multilib in Debian.)

Second, setup ocaml for 32bit. (e.g. See https://github.com/ocaml/ocaml/blob/trunk/INSTALL.adoc.)

Third, prepare 32bit-version GMP.

$ tar xf gmp-6.1.2.tar.xz
$ mkdir build && cd build
$ ../gmp-6.1.2/configure CC='cc -m32' ABI=32 --prefix=/opt/lib32gmp
$ make
$ make check
$ make install

MPFR can be compiled in the same way. MPC is a bit more complex.

(In Debian, you can get the 32bit-version packages by apt-get download libgmp-dev:i386 libmpfr-dev:i386 libmpc-dev:i386 instead of compiling them yourself.)

Then, specify OCAMLC and WITH_GMP to be used.

$ make OCAMLC=$HOME/.opam/4.08.0+32bit/bin/ocamlc WITH_GMP=/opt/lib32gmp

Cross compile

First, copy the sysroot from the target SDK (including GMP), and setup binutils and gcc for cross compiling. (e.g. See https://github.com/ytomino/drake/wiki/Setup-cross-compilers.)

Second, setup (flexdll and) ocaml for cross compiling. (e.g. See https://github.com/ocaml-cross/opam-cross-windows/blob/master/README.md for Windows.)

Then, specify OCAMLC to be used.

$ make OCAMLC=$HOME/.opam/4.08.0+32bit/windows-sysroot/bin/ocamlc
Clone this wiki locally