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.Prerequisites
In order to compile Gecode, you need a standard Unix toolchain including the following programs:
- a bash-compatible shell
- GNU make
- sed
- cp
- tar
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
- the Microsoft Visual C++ compilers for Windows. The Microsoft Visual C++ 2005 Express Edition is available free of charge from the MSDN web pages.
- the GNU Compiler Collection (gcc) for Windows and Unix flavors such as Linux and MacOS X. The GNU gcc is open source software and available from the GCC home page. It is included in all Linux distributions and the Apple MacOS X developer tools. Gecode requires at least version 3.4 of gcc. We recommend using version 4.0 or higher. Very unfortunately, the parser used in versions of gcc before 3.4 is broken and hence cannot compile Gecode.
- The Intel C++ compiler for Windows and Linux. Please note that this compiler was only tested using the evaluation license available from Intel. If you encounter problems or have suggestions for improvements, please let us know.
Configuring the sources
Gecode uses GNU autoconf to acquire information about the system it is compiled on. Typically, you need to run theconfigure
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
:
- When using the Microsoft Visual C++ compiler, add
CC=cl CXX=cl
to your invocation ofconfigure
- When using the Intel C++ compiler under Windows, add
CC=icl CXX=icl
to your invokation of configure. - When using the Intel C++ compiler under Linux, add
CC=icc CXX=icpc
to your invokation of configure. - To install Gecode somewhere else than the default
/usr/local
, use the--prefix=[...]
switch - You can enable and disable the individual modules Gecode consists of using
--enable-[MODULE]
and--disable-[MODULE]
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" \
SHELL="/bin/bash"
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 variableCXXUSR
. 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
make
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:
./examples/golomb
or (when running Windows):
./examples/golomb.exe
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).
Installation
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 callmake 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 duringconfigure
. There are two options to specify the type of platform:
--with-host-os=[linux|darwin|windows]
--with-compiler-vendor=[gnu|microsoft|intel]
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:
all
compiles all parts of the library that were enabled duringconfigure
, and the examples if enabledinstall
installs library, headers and examples (if enabled) into theprefix
given atconfigure
clean
removes object filesveryclean
removes object files, libraries, and all files + generated duringmake
distclean
removes object files, libraries, and all generated filesdepend
computes dependencies between source filestest
compiles the test suitedoc
generates this reference documentation using doxygeninstalldoc
installs the documentationdistdoc
creates tgz and zip archives of the documentationdistzip
creates a binary distribution as a zip archivedisttgz
creates a binary distribution as a tgz archive