OCaml Installation

The canonical installation instructions are in the Install OCaml section on the OCaml website. In the following we will give some course-specific hints.

MLH Computer Labs

OCaml version 3.11 installed under Windows on the lab computers is outdated. Although you will be able to follow the first examples of the course, you will not be able to use the Menhir parser generator later.

On the other hand, the versions of OCaml and Menhir installed under Linux are appropriate, and you will be able to do all programming work for the course on lab computers running Linux.

Linux

There are OCaml packages for most Linux distributions, including at least Debian, Ubuntu, and Fedora, as well as FreeBSD and most likely some other systems.

You will want to install the most current version of OCaml, which should be version 4.01, or, if you are lucky, the recently released version 4.02. Further, you should install the Menhir parser generator for OCaml, which comes packaged for the distributions listed above and should work with the OCaml version you installed.

OCaml has its own package manager called OPAM available for Linux and Mac OS X, which you may want to use if you are developing OCaml using more third-party libraries. It is a nice tool, but not necessary for this class.

Mac OS X

If you are using a package manager such as Fink, MacPorts or Homebrew, you're best off installing their respective packages.

You will want to install the most current version of OCaml, which should be version 4.01, or, if you are lucky, the recently released version 4.02. Further, you should install the Menhir parser generator for OCaml, which comes in its own package and should work with the OCaml version you installed. Note that the OCaml package is called objective-caml by Homebrew.

There is also OCaml's own package manager OPAM, which is useful if you are developing in OCaml using third-party libraries. It may be the easiest way for to install OCaml and Menhir on Mac OS X, follow the instruction in the Binary Installer section of the Quick Install Guide. You should download the file https://raw.github.com/ocaml/opam/master/shell/opam_installer.sh (In Safari open the page, choose Save As and make sure that you select Page Source, not Web Archive as the Format). Then open a Terminal, enter

cd ~/Downloads (or instead the directory you downloaded the file to)

and then

sudo sh ./opam_installer.sh /usr/local/bin

To install Menhir you enter

opam install menhir

As a last resort, you can find a Mac OS X binary package of the previous released version 4.01, but if you are using it, you will most likely have to compile the Menhir parser generator from sources. I could not find a Mac OS X installation package.

Windows

To install OCaml under Windows we recommend the Cygwin-based native Windows port, which should work on Windows XP, Windows 7, and Windows 8. Download the installer and run it to have it install OCaml and Cygwin. We recommend to choose C:/ as the installation path.

Before using OCaml and Cygwin, you need to set an environment variable. Right click the "My Computer" icon, choose "Advanced system settings", then "Enviroment Varibles". There is a row called "Path" under "System Variables". Add ;C:\cygwin\bin to it and click "OK".

To install the Menhir parser generator you need to download its source code from the Menhir website. Move the downloaded file into your C:/cygwin/home/username directory if you installed Cygwin in this directory before.

Run a Cygwin shell, go to the home directory, replace username with your user name.

cd username

Unpack the downloaded file, replace menhir-20140422.tar.gz with the name of the file you downloaded.

$ tar –xvzf menhir-20140422.tar.gz

Enter the directory that was created.

$ cd menhir-20140422

Compile and install Menhir.

make PREFIX=C:/cygwin all install

Finally, check if your Menhir is installed correctly.

menhir --version

Note: The OCaml installer comes with the 32 bit version of Cygwin. It works fine with a 64 bit Windows so you don’t need to download a 64 bit version. I had some problems trying to build the 64 bit Cygwin.

22c:111 (CS:3820)
Programming Language Concepts
Fall 2014

Lectures

Every Monday, Wednesday and Friday 1.30pm-2.20pm in W228 CB

Instructor

Dr. Christoph Sticksel
Email

Office hours

Every Tuesday 2pm-3.30pm and Friday 10.30am-12noon in 201K MacLean Hall.

Teaching Assistant

Jingwei Ji
Email

Office hours

Every Monday 3pm-5pm and Wednesday 3pm-5pm, 101N MLH