# Ocaml for Win Env

**URL:** <https://discuss.ocaml.org/t/ocaml-for-win-env/670>\
**Category:** Ecosystem\
**Tags:** windows, opam\
**Created:** [August 4, 2017, 3:27pm UTC](https://discuss.ocaml.org/t/ocaml-for-win-env/670 "2017-08-04T15:27:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![marco\_levantesi](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@marco\_levantesi](https://discuss.ocaml.org/u/marco_levantesi)\
**Post date:** [August 4, 2017, 3:27pm UTC](https://discuss.ocaml.org/t/ocaml-for-win-env/670/1 "2017-08-04T15:27:42Z")

</div>

Hello guys, I started to study ocaml language because i need it for my thesis article. So i have already done all steps from tutorial and i have only one thing to ask:

1. complete guide how to install ocaml for window environment

i follow this one -\> [http://ocaml.org/docs/install.html#Windows](http://ocaml.org/docs/install.html#Windows) and i tried all three ways how to install ocaml and when i used OCPWin + Ocaml Top i encountered some issues like “Unbound Module x” or install new package. Hence, i decided to use Cygwin + Ocaml64 (-\> [https://fdopen.github.io/opam-repository-mingw/installation/](https://fdopen.github.io/opam-repository-mingw/installation/)) and the question i have now is :  
the double terminal i got after installation wizard (cygwin terminal and Ocaml64 terminal) how i should use them? i tried to open Ocaml64 and run “ocaml” so i can easily use interpreter but i don’t know how save files.  
So I prefer use Ocaml Top as interface because is really comfortable, but if one of all you good guys could help to explain how use way with Cygwin and OCaml terminal i’ll appreciate so much.

---

<div class="post-metadata">

**Author:** ![fdopen](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/fdopen/32/452_2.png) [@fdopen](https://discuss.ocaml.org/u/fdopen)\
**Post date:** [August 4, 2017, 6:07pm UTC](https://discuss.ocaml.org/t/ocaml-for-win-env/670/2 "2017-08-04T18:07:20Z")

</div>

You can install OCaml Top with opam from the cygwin shell:

```bash
$ opam install -y depext depext-cygwinports # this will install ocaml-depext and its windows helper
$ eval $(ocaml-env cygwin) # adds external dependencies to your $PATH
$ opam depext -i -y ocaml-top # install ocaml-top and external dependencies

```

Now you can already start ocaml-top from cygwin:

```auto
$ ocaml-top

```

You can also add an link to the Desktop (or start menu, etc. see `mkshortcut --help` for other options)

```bash
$ mkshortcut --desktop --name='OCaml top' --arguments="exec ocaml-top" /usr/local/bin/ocaml-env.exe

```

---

<div class="post-metadata">

**Author:** ![marco\_levantesi](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@marco\_levantesi](https://discuss.ocaml.org/u/marco_levantesi)\
**Post date:** [August 5, 2017, 9:35am UTC](https://discuss.ocaml.org/t/ocaml-for-win-env/670/4 "2017-08-05T09:35:56Z")

</div>

Last question: after i run “ocaml-top” on cygwin terminal, i got this message

> C:/OCaml64/home/marco/.opam/4.03.0+mingw64/bin/ocaml-top.exe: error while loading shared libraries: libpango-1.0-0.dll: cannot open shared object file: No such file or directory

So maybe i prefer to reinstall cygwin only and then use your commands written above , but should i install opam first, right?

after downloaded setup here : [Cygwin Installation](https://cygwin.com/install.html) what i should do?  
thank you for your time and good answering

---

<div class="post-metadata">

**Author:** ![fdopen](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/fdopen/32/452_2.png) [@fdopen](https://discuss.ocaml.org/u/fdopen)\
**Post date:** [August 5, 2017, 10:00am UTC](https://discuss.ocaml.org/t/ocaml-for-win-env/670/5 "2017-08-05T10:00:04Z")

</div>

The \*dll files are either inside `C:\OCaml64\usr\x86_64-w64-mingw32\sys-root\mingw\bin` or `C:\OCaml64\usr\i686-w64-mingw32\sys-root\mingw\bin` - depending on your `Sys.word_size`. And you are free to use libraries provided by somebody else, e.g. [msys2.org](http://msys2.org), or compile them yourself manually. Because of the many different options, they are not added to your PATH automatically. You have to do it manually, either with

```bash
$ export PATH="/usr/x86_64-w64-mingw32/sys-root/mingw/bin:$PATH"
# or as mentioned above
$ eval $(ocaml-env cygwin)

```

---

<div class="post-metadata">

**Author:** ![marco\_levantesi](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@marco\_levantesi](https://discuss.ocaml.org/u/marco_levantesi)\
**Post date:** [August 5, 2017, 10:22am UTC](https://discuss.ocaml.org/t/ocaml-for-win-env/670/6 "2017-08-05T10:22:48Z")

</div>

thank you, i added manually to my environment variables on “path” file and now it seems all works. Last question and then , i thoguth i’m done :  
After downloaded setupx64 from this link [https://fdopen.github.io/opam-repository-mingw/installation/](https://fdopen.github.io/opam-repository-mingw/installation/) and run it, i got these two terminal, so are they the same or should i just use cygwin terminal and forgot about Ocaml64 terminal?

![img](https://us1.discourse-cdn.com/flex020/uploads/ocaml/original/1X/51c738533957466450c1657bfae6e4745b648a47.png)

And if i run “ocaml-top” in both of them, program Ocaml top will start at same way.

---

<div class="post-metadata">

**Author:** ![fdopen](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/fdopen/32/452_2.png) [@fdopen](https://discuss.ocaml.org/u/fdopen)\
**Post date:** [August 5, 2017, 10:34am UTC](https://discuss.ocaml.org/t/ocaml-for-win-env/670/7 "2017-08-05T10:34:06Z")

</div>

Yes, you can delete one link. There should be no functional difference between them. I looks like cygwin’s setup.exe ignores the command line parameter, that was intended to prevent the creation of one of the links.

---

<div class="post-metadata">

**Author:** ![marco\_levantesi](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@marco\_levantesi](https://discuss.ocaml.org/u/marco_levantesi)\
**Post date:** [August 5, 2017, 10:41am UTC](https://discuss.ocaml.org/t/ocaml-for-win-env/670/8 "2017-08-05T10:41:00Z")

</div>

i tried exec this example from tutorial and when i encountered two different error message, could you explain that?  
first:

![img2](https://us1.discourse-cdn.com/flex020/uploads/ocaml/original/1X/9a6a2a00a756b750779da58536f3c7500a49151e.png)

you can find example here [http://ocaml.org/learn/tutorials/introduction\_to\_gtk.html](http://ocaml.org/learn/tutorials/introduction_to_gtk.html)

I promise, this is last one 😃

---

<div class="post-metadata">

**Author:** ![marco\_levantesi](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@marco\_levantesi](https://discuss.ocaml.org/u/marco_levantesi)\
**Post date:** [August 5, 2017, 10:41am UTC](https://discuss.ocaml.org/t/ocaml-for-win-env/670/9 "2017-08-05T10:41:33Z")

</div>

second:

 ![example_from_tutorial](https://sea2.discourse-cdn.com/flex020/uploads/ocaml/original/1X/c39e932da0a1ad1677e7e8bacbbb7c3d33f6ceec.png)
