Jun 13, 2011

Configure Visual studio C++ 2008 express edition with IBM Ilog Cplex and Concert libraries

I posted a couple of days ago , a Makefile for C++ project using IBM-ILOG cplex solver and the Concert library. So I thought I should do the same thing for the windows guy. First you ll need a Visual studio, i recommend VS 2008 C++ express edition, why speeding your money on a non worthy C++ editor, ( I ll try to configure netbeans on windows to bypass the VS )
First you need to create an empty C++ application

1 - Then you go to your project Menu and choose properties.

2 - In the configuration manager, change the configuration from debug mode to Release ( If you are going to use concert ; you have to program without debugging as it uses macros incompatible with the debug flags that the compilor add to your code), that the price that you have to pay with concert it's a double eddged sword. You write less code, but if you have an error you have to start guessing and trust me you could loose a lot of your time guessing and trying to figure out what went wrong.

3- You need to change compiler flags ( aka C/C++ in the configuration settings)

In order to use any C++ library you need the library itself .lib and the Header files (*.h or *.hpp). The lib 's header files indicate the compiler to the content of the lib file( a sort of Table of content). So when you compile your code, the compiler only check if the function you are calling figures in the header files and that you are using the proper argument to make the call. After the compilation of your cpp files into object files , the assembler / linker will link your compiled code (*.o) with acttuel function in the lib and produce the executable.

In our case we need to tell the compiler the path to the header files for cplex and concert libs .So you will need to add the path in the Additional Include Directories. you can use the small button on the path line to choose via explorer the directories. ( there is two include folders that you need: the cplex include folder and another include folder in the concert folder )

4-Disable the debug information format ( It could be that it's not required any more)

5 -Add IL_STD to the preprocessor definition ; it's the equivilant of -D in gcc , you can a define IL_STD at begining of your main file; i didn't check the files in the cplex include directory to see exactly what is the effect of this option . And also It could be that its not used any more

6-I don't remmeber why, but I usually choose MT as a Runtime library and in the next section I choose the library in the in stat mta ( I could be wrong , may be you can check if there is any impact on the speed of the execution )

7 - After the compilation you need to assamble your code. The linker wil assemble all the .o files into an executable and will need the libraries that you are calling to make the final excutable. You need to add to the Additional Dependencies in Input section of the linker , the exact location of you cplex library and concert + winsoc32 lib

In my case I had to add the following line :

Tip Use ( use the windows explorer aka my computer ) , browse to the folder in question then right click on folder hiearchy satuts bar and copy the path

No comments: