Setting Up cygwin and OCaml

Scott McPeak   George Necula

This document is intended to get you started with OCAML and the other tools that are necessary for CCured and other projects of ours. These tools work on Linux and Windows (NT4.0, 2000, XP and also less reliably on 95/98/Me).

If you use Linux then you can go directly to Section 2.

1  If you want to use Windows

1.1  Get cygwin

You must have a bunch of Unix tools installed on your machine. (In the future we might be able to avoid these but for now you are better off with them.). Here is what I (George) do to install Cygwin. You need a good network connection for this.

2  Get OCaml

The next step for most people is to download and install the Ocaml compiler system. This is available at:

http://caml.inria.fr/ocaml/

At the time of writing, the current version is 3.04. The following instructions assume that you will build from sources even on Windows (instead of using the Native compiler provided). Here the rough sequence of steps: To test your ocaml distribution, try:
  % which ocaml
  /usr/local/bin/ocaml

  % ocaml
        Objective Caml version 3.02

  # exit 0;;    <-- you type "exit 0;;", and press enter
If you intend to program in Ocaml then you should also install the emacs support files for ocaml. This will give you nice fontification and indentation. If you check in code that is not indented nicely some members of the project will not be pleased!

2.1  Debugging Support Ocaml

If you expet to need to run the debugger our projects are set up in such a way that they will invoke the debugger for you. How to do that is described in each project's documentation. But for that support to work you must add the following code to your .emacs file:
(defvar ocamldebug-history nil)
(defun my-camldebug (command-line)
  "Run camldebug on program FILE in buffer *camldebug-FILE*.
The directory containing FILE becomes the initial working directory
and source-file directory for camldebug.  If you wish to change this, use
the camldebug commands `cd DIR' and `directory'."
  (interactive
   (list (read-from-minibuffer "Run ocamldebug (like this): "
          (if (consp ocamldebug-history)
       (car ocamldebug-history)
     "ocamldebug")
                                 nil
                               nil
          '(ocamldebug-history . 1))))
  ; call something from camldebug.el to make sure it is loaded
  (camldebug-numeric-arg 1)
  (pop-to-buffer (concat "*camldebug*"))
  (setq words (gud-chop-words command-line)) 
  (message "Current directory is %s" default-directory)
  (apply 'make-comint (cons "camldebug"
                      (cons (car words)
                      (cons nil (cdr words)))))
  (set-process-filter (get-buffer-process (current-buffer))
                      'camldebug-filter)
  (set-process-sentinel (get-buffer-process (current-buffer))
                        'camldebug-sentinel)
  (camldebug-mode)
  (camldebug-set-buffer))

3  Set the environment variables

Make sure that /usr/local/lib in in your path. If you are on Windows this means ``C:/Programs/cygwin/usr/local/lib''.

4  Useful Links


This document was translated from LATEX by HEVEA.