Features » Portability

OCaml makes it quite simple to write portable programs which will work across Windows, Mac OS X, Linux and Unix from a single codebase.

This page describes the choices available to companies that need to write programs across all platforms.

Command line, background, server programs

Cross platform programs without a Graphical User Interface (GUI) can easily be written directly in OCaml. To port such programs to Windows, simply avoid using a few Unix-specific features of the standard library. See the OCaml manual.

Graphical (GUI) programs

To develop successful cross-platform programs with Graphical User Interfaces (GUIs), simply choose the right cross-platform library.


The right cross-platform library usually is Gtk, which has comprehensive OCaml bindings called lablgtk2. Gtk is available on Windows, Linux and Unix. Gtk for Mac OS X requires the Apple X Server subsystem, which usually is only an issue for those running Mac OS X versions before 10.3.

Gtk Wimp is a Windows theme which makes Gtk programs running under Windows look like native Windows programs. Gtk Wimp is fully integrated into Gtk.


WxWidgets (formerly called WxWindows) is a library which supports fully native widgets on the Windows, Mac, Linux and Unix platforms. WxCaml, an OCaml binding for WxWidgets is available.

WxWidgets has support for native file and print dialogs, but has limited support for rich text editing and canvases.

Build environment

When developing a cross-platform application with OCaml, we recommend the OMake Build System. OMake is an alternative to GNU Make and the GNU tools that was developed in OCaml. OMake's library of default build recipes has extensive support for OCaml programs.

For platform independent version control, we strongly recommend Concurrent Versioning System (CVS).

Alternatives to CVS include Subversion and Arch.


Since every platform has its own packaging system and installation requirements, there is no "cross-platform installer". However, a Makefile-based build environment allows one to easily generate packages for each platform.

On Windows we suggest using NSIS which has a simple text-based configuration file and can be driven from a Makefile.

On Linux you can build either RPMs or Debian DEBs using the standard tools.

Case studies

People simulator (Summer 2003)

This cross-platform (Windows, Linux, Solaris) simulation system modelling agent based processes with special interest on through-put and costs under resource and policy changes. The rich graphical front-end was implemented using Gtk and lablgtk.

On the Windows platform, the software could be completely installed from a single package which was created using NSIS. On Linux we built an RPM.

During development, developers working concurrently on Linux and Windows using CVS for coordination. Developers used either a Makefile-based build process or (on Windows only) Visual Studio.