# Installing OCaml for 3110 You need to have a working installation of OPAM, the OCaml Package Manager. You have a choice: you can install OPAM natively on your own operating system, or you can download a Unix virtual machine (VM) that we provide in which OPAM is already installed. Regardless, be aware that **OCaml version 4.03.0 is the only supported version** of the OCaml compiler in CS 3110 this semester. All your code must compile under that version. (It is the version already installed in the VM.) * **If your operating system is Linux or OS X**, we suggest trying a native installation first. If that doesn't work out, install the VM instead. * **If your operating system is Windows**, install the VM. Not only can it be difficult to get OPAM running under Windows, but one of the secondary goals of this course is that you become comfortable working in a Unix environment. [homebrew]: http://brew.sh/ [MacPorts]: https://www.macports.org/ #### VM installation WARNING: Do not use a VM from an old edition of CS 3110. Only the Fall 2016 VM will be supported this semester. * Download and install [VirtualBox][vbox] for your operating system. Make sure you have the latest version before proceeding. * Download either the [64-bit version][3110vm-64] of the 3110 virtual machine or the [32-bit version][3110vm-32]. Most people will want the 64-bit version. If you're not sure which you need, [this article][32vs64] might help. If you're still not sure, try the 64-bit version first, and if it fails to start, try the 32-bit version. * Import the virtual machine: - Run VirtualBox. - Select File → Import Appliance - Choose the `.ova` file you just downloaded and import it. * Run the virtual machine: - Select csvm-2016fa (or csvm-2016fa-32, if you are using the 32-bit version) from the list of machines in VirtualBox. - Click Start. * Login with username "ubuntu" and password "ubuntu". *Don't login with the guest account. Be aware that if you create a new user, OPAM won't be intialized for that user; you would need to run the OPAM initialization commands provided below under "Native installation".* * To launch the OCaml toplevel: - Start a terminal by choosing the 4th icon down from the top in the launcher on the left-hand side of the desktop. - Run `utop`. - Enter `#quit;;` to exit the toplevel. * When you use VirtualBox to shut down the VM, you will be presented with three choices: save the machine state, shutdown the machine, or power it off. **DO NOT CHOOSE POWER OFF.** That is the equivalent of pulling the power cord of a desktop machine from the wall: it causes the operating system to suddenly quit without doing any cleanup. Repeatedly doing that will cause the file system to become corrupted, which will cause you to lose data and have to reinstall the VM. Most commonly you probably want to save the machine state, which is like putting your laptop in hibernate/sleep mode. Shutdown is like pushing the power button. [vbox]: https://www.virtualbox.org/wiki/Downloads [3110vm-64]: https://cornell.box.com/v/cs3110vm-2016fa-64 [3110vm-32]: https://cornell.box.com/v/cs3110vm-2016fa-32 [32vs64]: http://www.computerhope.com/issues/ch001121.htm #### Native installation * If your operating system is OS X, you'll first need to install either [homebrew][] or [MacPorts][] as a Unix package manager. If you don't already have one or the other installed, MacPorts might be preferable. If you previously installed one of them, then upgraded your OS X version, be especially careful: these package managers don't survive such upgrades easily. Make sure your package manager is in working order before proceeding. * Download and install [OPAM][opam] for your operating system. * Enter the following commands in a terminal to initialize OPAM and install some packages that will be needed for CS 3110: ``` opam init -a -y --comp 4.03.0 eval `opam config env` opam install -y utop ounit qcheck yojson lwt menhir ``` * Run `utop` to launch the OCaml toplevel. Enter `#quit;;` to exit the toplevel. [opam]: https://opam.ocaml.org/doc/Install.html