opam.exe is intended to be used from within cygwin. If you want to
install additional libraries or upgrade existing packages, you should
do it inside a cygwin terminal (mintty/rxvt-unicode,…).
Once everything is installed, you are not longer depended on cygwin.
You can build your project from cmd.exe, powershell, your editor,
etc. However, you have to configure your build environment
properly. Your c compiler/linker (msvc or mingw-w64), cygwin (used
internally by mingw/flexlink), and ocaml/opam all require special
changes to the environment (
ocaml-env is a little helper to combine these different steps into
one single call.
Run a program with the proper environment settings, e.g:
Note the difference between ‘ocaml-env.exe exec – ..’ and ‘ocaml-env-win.exe – ..’. Use the former to start console based applications, the latter to start GUI applications.
ocaml-env is also useful, if you want to configure your environment
for the msvc toolchain from within cygwin. E.g if you intend to use
Visual Studio 2015 to compile OCaml:
--no-opam switch is necessary, because
4.04+msvc64 is not yet
installed and we don’t want to include opam environment settings from
--64 is necessary in order to add the environment
variables for the right architecture. You can omit both once your
compiler is installed:
If you have only one Microsoft toolchain installed, you could in
theory now also omit
--ms=vs2015. But I’m not sure, if the
auto-detection of program paths works very well. Open
an issue, if
you encounter any problem.
If you use depext-cygwinports,
ocaml-env will add
/usr/x86_64-w64-mingw32/sys-root/mingw/bin to your PATH,
$(ocaml-env cygwin) might be preferable to
eval $(opam config
ocaml-env --help for further details.