Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.
Jonathan Protzenko edited this page Jun 10, 2016 · 27 revisions

These are the (most comprehensive) instructions to get a working OPAM setup.

These instructions are optimized towards compiling miTLS and F*.

Sanity checks

  • Open up a cmd.exe prompt, and make sure that typing bash and tar results in a 'bash' is not recognized as an internal or external command error. If cmd.exe picks up any of these two programs, uninstall them. Possible culprits:
    • bash for windows (the new linux syscall emulation layer in windows 10)
    • gnu on windows
    • git for windows (comes with its own msys distribution)
    • msys
    • etc. etc.
  • If you already have cygwin installed: make sure it's cygwin64 (uname -a).
  • If you already have cygwin installed: open up a cygwin terminal, and run where ocaml and where flexlink. If you get anything at this stage, clean up. Possible culprits include:
    • cygwin packages for ocaml and flexdll; remove these!
    • leftover Wodi setup
    • leftover old OCaml setup (e.g. the old 3.11 installer, ocpwin, etc.)
  • Open up a cmd.exe prompt, and run set. If you have any environment variable for OCaml (e.g. OCAMLLIB), clean it up using your system properties → environment variables dialog.

Run the installer

Download and launch the installer from http://protz.github.io/ocaml-installer/; follow the setup instructions and make sure all of the packages below are installed.

Note: on Windows 8.1 and above, the OCaml installer will fail to launch Cygwin's setup.exe. In that case, launch it manually (it has been downloaded to your desktop).

Here's the list of packages you'll need (the installer doesn't pre-check all of them).

  • wget
  • make
  • automake
  • m4
  • mingw64-x86_64-gcc-core
  • mingw64-x86_64-pkg-config
  • patch
  • rlwrap
  • libreadline
  • diffutils
  • unzip
  • mingw64-x86_64-openssl
  • mingw64-x86_64-sqlite3
  • mingw64-x86_64-gmp

Run the second part of the sanity check again, to make sure you still have one ocaml and one flexlink binary.

Configure your initial OPAM setup

Run opam init, and decline to let it customize your ~/.bash_profile. Instead, add the following to your ~/.bashrc:

export CAML_LD_LIBRARY_PATH=$HOME/.opam/system/lib/stublibs:/cygdrive/c/OCaml/lib/stublibs
export MANPATH=$HOME/.opam/system/man:$MANPATH
export PATH=$HOME/.opam/system/bin:/usr/x86_64-w64-mingw32/sys-root/mingw/bin/:$PATH

Run source ~/.bashrc in any (open) terminals to get the new (proper) environment.

Install depext-cygwinports

opam install depext-cygwinports

Theoretically not needed now that the x86_64-mingw32-* packages are in the mainstream Cygwin repo, but the special fixes in fdopen's repository won't kick in until this is installed.

Install a bunch of opam packages

Run opam install zarith batteries stdint fileutils sqlite3.

If opam fails to install a package (e.g. sqlite3), try again opam install sqlite3.

Troubleshooting

  • If OPAM complains that the system dependency on GMP cannot be found, and if you're positive that the cygwin package mingw64-x86_64-gmp is installed, then open the Cygwin terminal and fake the installation of OPAM package conf-gmp:
$ opam install --fake conf-gmp
  • If, building miTLS, you get:
** Cannot resolve symbols for C:/cygwin/home/protz/.opam/system/lib/sqlite3\libsqlite3_stubs.a(sqlite3_stubs.o):
 sqlite3_enable_load_extension

then:

opam remove sqlite3
export SQLITE3_DISABLE_LOADABLE_EXTENSIONS=1
opam install sqlite3
  • OPAM pretends to call curl but really it's only calling wget; make sure wget is installed
  • make sure your OCaml executable is the right one (where ocaml)
  • make sure OCAMLLIB is properly set using a Windows-style path (e.g. C:\OCaml\lib). This is known to cause opam install sqlite3 to fail.
  • check the output of ocamlopt -config (should contain native_c_compiler: x86_64-w64-mingw32-gcc -O -mms-bitfields -Wall -Wno-unused)

Bonus

You can install opam install depext-cygwinports, so that opam depext is aware of Cygwin packages that need to be installed. But, this shouldn't be needed if you installed the right packages already.

Clone this wiki locally