RSS
 

CPLEX in C++ using Eclipse under Linux (Ubuntu)

18 mag

Installing CPLEX on a linux box is quite easy. I did it on Ubuntu: just download the package which is appropriate for your architecture (I downloaded a 32 bit version for x86), make sure it’s executable and sudo run it. That should be about it, unless customization is needed.

The documentation describes how to test the installation from the command line. However, I wanted to use it for C++ from within Eclipse, so I looked for the parameters in the documentation. In particular, look for the page called Setting up CPLEX for on GNU/Linux: it contains all includes, libraries, symbols, etc.

Create a C++ project (a “Hello World” is fine). Right click on the project folder or click on project and select Properties. Select C/C++ Build -> Settings -> Tool Setings (tab):

  1. in GCC C++ Compiler menu:
    1. Preprocessor
      1. Defined Symbols (-D) click and add “IL_STD” (without quotes)
    2. Includes
      1. click and add directory path. Click on File System and select the directories. On my installation I had to add but please choose appropriate version and architecture:
        • /opt/ibm/ILOG/CPLEX_StudioXYZ/cplex/include and
        • /opt/ibm/ILOG/CPLEX_StudioXYZ/concert/include
  2. No need to add anything in GCC C Compiler menu but, in case you wish to, do the same as for C++, except concert.
  3. in GCC C++ Linker menu:
    1. Libraries
      1. Libraries (-l): add in the following order:
        1. ilocplex
        2. concert
        3. cplex
        4. m
        5. pthread
      2. Library search path (-L): click and add directory from File System (please choose appropriate version and architecture):
        1. /opt/ibm/ILOG/CPLEX_StudioXYZ/cplex/lib/arch_ver/static_pic
        2. /opt/ibm/ILOG/CPLEX_StudioXYZ/concert/lib/arch_ver/static_pic

That’s it! Just replace your main with the example code shipped in the documentation at Using Concert Technology in C++, compile and run it :-)




 
No Comments

Posted in geek

 

Tags: , , , , , , , , ,

Leave a Reply

 

 
 
%d bloggers like this: