Using the C++ interface

Explains how to compile and build an application that uses OPL C++ interfaces. For details, see the C++ interface reference manual.

The C++ API of OPL is based on the C++ Concert Technology, on the CPLEX C++ API, and on the CP Optimizer API which are themselves based on Concert Technology. For more information, see the optim.concert group in the C++ interface reference manual.

To compile and build an application that uses OPL C++ interfaces:

  1. Include the directory of header files:

    <Install_dir>\opl\include

  2. Link with the following IBM ILOG libraries:
    Windows libraries Unix libraries
    concert.lib concert.so
    cp.lib cp.so
    cplexversion_number.lib cplexversion_number.so
    dbkernel.lib dbkernel.so
    dblnkdyn.lib dblnkdyn.so
    iljs.lib iljs.so
    ilocplex.lib ilocplex.so
    ilog.lib ilog.so
    opl.lib opl.so

    These libraries are in the following directory:

    <Install_dir>\opl\lib\<port_name>\<format>

    where <Install_dir> is your installation directory.

  3. Set your environment variable.
    • On Windows, make sure that the path

      <Install_dir>\opl\bin\<port_name>

      is in your PATH environment variable, so that the shared .dll libraries are found. Applications need these shared libraries to run correctly.

    • On Unix, make sure that

      <Install_dir>\opl\bin\<port_name>

      is in your LIBPATH or LD_LIBRARY_PATH environment variable, so that the shared libraries are found. Applications need these shared libraries to run correctly.

    Note:

    To see the solution in your file, you have to force the flush of the output stream, using

    cout<<endl;

    For more information and examples on how to use Concert Technology, as well as the CPLEX and CP Optimizer APIs for Concert Technology, see the Concert, CPLEX and CP Optimizer documentation.