-
Notifications
You must be signed in to change notification settings - Fork 11
Home
These are the (most comprehensive) instructions to get a working OPAM setup.
These instructions are optimized towards compiling miTLS and F*.
- Open up a
cmd.exe
prompt, and make sure that typingbash
andtar
results in a'bash' is not recognized as an internal or external command
error. Ifcmd.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
andwhere flexlink
. If you get anything at this stage, clean up. Possible culprits include:- cygwin packages for
ocaml
andflexdll
; remove these! - leftover Wodi setup
- leftover old OCaml setup (e.g. the old 3.11 installer, ocpwin, etc.)
- cygwin packages for
- Open up a
cmd.exe
prompt, and runset
. If you have any environment variable for OCaml (e.g.OCAMLLIB
), clean it up using your system properties → environment variables dialog.
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 Cygwin packages you'll need (the installer doesn't pre-check all of them).
- automake
- diffutils
- libreadline
- make
- m4
- mingw64-x86_64-gcc-core
- mingw64-x86_64-gmp
- mingw64-x86_64-openssl
- mingw64-x86_64-pkg-config
- mingw64-x86_64-sqlite3
- patch
- rlwrap
- unzip
- wget
Run the second part of the sanity check again, to make sure you still have one ocaml
and one flexlink
binary.
In Cygwin Terminal, 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.
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.
Run opam install zarith batteries stdint fileutils sqlite3 yojson
.
If opam
fails to install a package (e.g. sqlite3
), try again opam install sqlite3
.
-
If OPAM complains that it cannot install a file into
~/.opam/system/bin
because it already exists, for instance:# install: cannot create regular file '/cygdrive/d/cygwin/home/protz/.opam/system/bin/bdump': File exists
then you're hitting https://github.com/ocaml/opam/issues/2313 and you need to remove locally the
package.install
file. In this case:rm ~/.opam/repo/default/packages/biniou/biniou.1.0.12/files/biniou.install
-
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 callingwget
; make surewget
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 causeopam install sqlite3
to fail. -
check the output of
ocamlopt -config
(should containnative_c_compiler: x86_64-w64-mingw32-gcc -O -mms-bitfields -Wall -Wno-unused
)
-
Installing ppx_deriving and friends: you need these two commands:
protz@Joprotze-Z420:~/.opam/system/lib $ find . -iname '*.cmxs' -exec chmod a+x {} \; protz@Joprotze-Z420:~/.opam/system/lib/ppx_deriving $ cp ppx_deriving ppx_deriving.exe
-
Installing ctypes: first, you need the libffi library installed in Cygwin, but in a MinGW variant. So, you must start cygwin-setup-x86_64.exe and choose installation of a package named:
mingw64-x86_64-libffi
(not simple "libffi"). After installing it, you can verify by typing in Cygwin Terminal:pkg-config --list-all
(it should show "libffi"). -
Installing and running utop: After successfully installing through Cygwin Terminal with
opam install utop
(note: you'll need the hint above in "Troubleshooting" about removing .install files), you will see a message:=-=- utop.1.19.3 installed successfully -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= => UTop does not work inside a cygwin terminal (mintty, urxvt,...). Use cmd.exe, ConsoleZ or a similar terminal emulator.
so, you can't run utop in Cygwin Terminal, but you must do this in normal cmd.exe window. For this to work correctly, you must set your PATH properly. To make it slightly easier, while still in Cygwin Terminal, type the following:
cd $HOME && cmd /c start cmd
It should start a new cmd.exe window, with Cygwin environment variables already set (specifically, $HOME). There, you should be able to start utop by typing the following commands:
set PATH=%HOME%\.opam\system\bin;%PATH% set PATH=%HOME%\.opam\system\lib\stublibs;%PATH% utop
opam depext foobar
should now be able to install the right Cygwin packages for your toolchain
See the solution here: https://gist.github.com/k-takata/9b8d143f0f3fef5abdab#solution-2-disable-db-in-etcnsswitchconf