Compiling and linking against Gecode
Including header files
Deciding which header files must be included when using Gecode is quite straightforward. There are the following header files for inclusion:- gecode/support.hh must always included (support.hh header is included from kernel.hh)
- gecode/kernel.hh must always be included (the header files below also always include kernel.hh).
- gecode/search.hh must be included, if search engines are used (see for example Search engines).
- gecode/int.hh must be included, if any integer functionality is used (see for example Using finite domain integers and Programming integer actors).
- gecode/set.hh must be included, if any finite set functionality is used (see for example Using finite integer sets and Programming set actors).
- gecode/cpltset.hh must be included, if any complete finite set functionality is used (see for example Using finite integer sets with complete domain representation and Programming CpltSet actors).
- gecode/minimodel.hh must be included, if direct modelling support is used (see for example Direct modelling).
- gecode/serialization.hh must be included, if support for serialization is used.
Other functionality is available through a set of header files. For example to access the implementation of particular propagators, a particular header file must be included. The header file to be included is always mentioned in the documentation of the class or function.
Linking libraries
Setting the exact name for a library on a particular platform aside, inclusion of header files basically coincides with against which library must be linked. That is:- If gecode/support.hh is included, linking againg the support library is required.
- If gecode/kernel.hh is included, linking against the kernel library is required.
- If gecode/search.hh is included, linking against the search library is required.
- If gecode/int.hh is included, linking against the integer library is required.
- If gecode/set.hh is included, linking against the set library is required.
- If gecode/cpltset.hh is included, linking against the cpltset library is required.
- If gecode/minimodel.hh is included, linking against the minimodel library is required.
- If gecode/serialization.hh is included, linking against the serialization library is required.
The functionality in Range and value iterators requires no library for linking. Reusing integer or set propagators of course require the integer or set library.
If there is a difference between library and DLL (such as on Windows) linking must be done against the appropriate library and the corresponding DLL must be available for execution (such as in the PATH environment variable).
The libraries contain code that is executed at link time (for registering part of the reflection functionality). If you create static libraries, this code will not be linked into your executable as it is not directly referenced. You will have to tell your linker to include all symbols from the library (e.g. using -Wl,--whole-archive on Linux). Please refer to your linker documentation.
Library names
Windows with Visual Studio
- Support library and DLL: GecodeSupport.lib and GecodeSupport.dll
- Kernel library and DLL: GecodeKernel.lib and GecodeKernel.dll
- Search library and DLL: GecodeSearch.lib and GecodeSearch.dll
- Integer library and DLL: GecodeInt.lib and GecodeInt.dll
- Set library and DLL: GecodeSet.lib and GecodeSet.dll
- CpltSet library and DLL: GecodeCpltSet.lib and GecodeCpltSet.dll
- Minimodel library and DLL: GecodeMiniModel.lib and GecodeMiniModel.dll
- Serialization library and DLL: GecodeSerialization.lib and GecodeSerialization.dll
Unix (Linux, MacOS X)
Depending on whether Gecode was compiled as a static or as a dynamic library, different filename suffixes are used on different Unix platforms. All library names follow the following scheme:
- Support library: libgecodesupport.<EXT>
- Kernel library: libgecodekernel.<EXT>
- Search library: libgecodesearch.<EXT>
- Integer library: libgecodeint.<EXT>
- Set library: libgecodeset.<EXT>
- CpltSet library: libgecodecpltset.<EXT>
- Minimodel library: libgecodeminimodel.<EXT>
- Serialization library: libgecodeserialization.<EXT>
where <EXT> depends on the library type and platform:
- libgecode[...].a for static libaries on all Unix flavors
- libgecode[...].so for shared libraries on Linux
- libgecode[...].dylib for shared libraries on MacOS X
You can use for example
gcc -L$GPREFIX/lib -lgecodekernel
to link the kernel library, if the libraries are found in $GPREFIX/lib
.