How to compile Gecode in Visual Studio 2008
Gecode is a powerful set of libraries for solving constraint-based problems that is available for free. It's written in C++ and can be compiled with a wide range of compilers on many different systems. In this post I explain the configuration changes that I needed to perform to use the libraries in Visual Studio. Gecode has a
page that describs how to use their library with Visual Studio but I found that a few steps were missing. Here's the steps that I used to be able to use Gecode in Visual Studio.
- Download and install the windows installer package. I installed it to C:\Program Files\Gecode
- Set up the include directories:
- Right click on the project --> Properties
- Open the Configuration Properties --> C/C++ --> General Tab
- Set the option Additional Include Directories to the value "C:\Program Files\Gecode\include"
- Set up the library directories:
- Right click on the project --> Properties
- Open the Configuration Properties --> Linker --> General Tab
- Set the option Additional Library Directories to the value "C:\Program Files\Gecode\lib"
- If you try to compile right now you will probably see a message like this one:
" ... fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' ... "
To fix this problem the easiest solution is to turn off precompiled headers. Although this may increase compile time the increase will likely not be very significant.
To turn off precompiled headers:
- Right click on the project --> Properties
- Open the Configuration Properties --> C/C++ --> Precompiled Headers Tab
- Set the option Create/Use Precompiled Header to the value Not Using Precompiled Headers