Generated on Wed Nov 1 15:04:52 2006 for Gecode by doxygen 1.4.5

Compiling and installing Gecode

The Gecode library, including examples and documentation, can be built on all recent versions of Windows, Linux, and MacOS X. Porting to other Unix flavors should be easy, if any change is necessary at all.


In order to compile Gecode, you need a standard Unix toolchain including the following programs:

These are available in all standard installations of Linux. On MacOS X, you need to install the Apple developer tools. For Windows, we require the Cygwin environment that provides all necessary tools.

We currently support

Configuring the sources

Gecode uses GNU autoconf to acquire information about the system it is compiled on. Typically, you need to run the configure script in the toplevel directory.

To setup Gecode for your particular system, you may need to add one or more of the following options to configure:

You can get a list of all supported configuration options by calling configure with the --help switch.

Example configurations

To compile Gecode on a Windows machine using the Microsoft compiler, use

./configure CC=cl CXX=cl

To compile only the Gecode library without examples on a Unix machine, use

./configure --disable-examples

To compile on a Unix machine using a different than the default gcc compiler, and install under /opt/gecode, use

./configure --prefix=/opt/gecode CC=gcc-4.0 CXX=g++-4.0

To compile a debug build on Unix, turning on all assertions and not inlining anything, use

./configure --enable-debug

To compile on Cygwin, but linking against the Windows libraries instead of the Cygwin libraries, use

./configure CC="gcc -mno-cygwin" CXX="g++ -mno-cygwin"

To compile on a system using a different than the default compiler, and a /bin/sh that is not bash compatible (e.g. a Solaris machine), use

./configure --with-host-os=linux \
   CC="gcc-4.0" CXX="g++-4.0" \
make SHELL="/bin/bash"

You can compile as "universal binary" on a Mac OS machine. Configure with

./configure --enable-universal

For building universal binaries on a PowerPC machine, you have to supply the path to the universal SDK (which is the default on Intel based Macs):

./configure --enable-universal    --with-sdk=/Developer/SDKs/MacOSX10.4u.sdk

Passing options for compilation

Additional options for compilation can be passed to the compiler from the make commandline via the variable CXXUSR. For example, to pass to gcc the additional option "-mtune=i686" the following can be used:

make CXXUSR="-mtune=i686"

Compiling in a separate directory

The Gecode library can be built in a separate directory. This is useful if you do not want to clutter the source tree with all the object files and libraries.

Configuring Gecode in a separate directory is easy. Assume that the sources can be found in directory $GSOURCEDIR, change to the directory where you want to compile Gecode and call

$GSOURCEDIR/configure [options]

This will generate all necessary files in the new build directory.

Compiling the sources

After successful configuration, simply invoking


in the toplevel Gecode directory will compile the whole library.

Running the examples

After compiling the examples, they can be run directly from the command line. For instance, try the Golomb Rulers Problem:


or (when running Windows):


On some platforms, you may need to set environment variables like LD_LIBRARY_PATH (Linux) or DYLD_LIBRARY_PATH (Mac OS) to the toplevel compile directory (where the dynamic libraries are placed after compilation).

For more information on example scripts see Example scripts (models).


After a successful compilation, you can install the Gecode library and all header files necessary for compiling against it by invoking

make install

in the build directory.

Dependency management

The dependencies between source files are not handled automatically. If you are using a Gecode version from our subversion repository or if you modified any of the source files, you will have to call make depend before compilation in order to determine the source dependencies.

Dependency management is only needed for recompiling Gecode after changing something. In an unmodified version (or after a make clean) all files are compiled anyway.

Compiling for unsupported platforms

If you want to try compiling Gecode on a platform that we do not support officially, you can override the platform tests during configure. There are two options to specify the type of platform:

Using the first option, you can state that your platform should behave like Linux, Darwin (which is actually BSD), or Windows. This affects mainly the filenames and the tools used to generate shared and static libraries.

The second option says that your compiler can be used very much like the gnu compiler gcc, the Microsoft compiler cl, or the Intel compiler icl. Please let us know of any successfull attempt at compiling Gecode on other platforms.

Makefile targets

The main Gecode Makefile supports the following useful targets: