Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  Linking error in program using CPLEX C++ API on Linux

    Posted Sat January 16, 2021 10:25 PM

    Hello Dear, I am using the C ++ API for CPLEX 12.9 in Linux / Centos and I perform the execution and linking of the dependencies as follows:

    g++ -std=c++11 main.cpp vrp.cpp vrp.h -I/opt/ibm/ILOG/CPLEX_Studio129/cplex/include -I/opt/ibm/ILOG/CPLEX_Studio129/concert/include -L/opt/ibm/ILOG/CPLEX_Studio129/cplex/lib/x86-64_linux/static_pic -L/opt/ibm/ILOG/CPLEX_Studio129/concert/lib/x86-64_linux/static_pic -o hardprogram

    But I cannot generate the compiled one I get several errors. Will I be linking the dependencies well?

    regards!






    #DecisionOptimization
    #Support
    #SupportMigration


  • 2.  RE: Linking error in program using CPLEX C++ API on Linux

    Posted Tue January 19, 2021 08:58 AM

    Hello,

    hard to answer without knowing the errors. However you can try to compile one of the delivered examples. If it doesn't work then give us please the error messages. Otherwise you can copy the compilation options.

    To compile delivered examples go to cplex/examples/x86-64_linux/static_pic inside your installation. And there you can compile all examples by typing just "make". Or you can compile one of the examples that are using Concert (it seems you'r using it too) by e.g. "make fixcost1".

    Regards, Petr






    #DecisionOptimization
    #Support
    #SupportMigration


  • 3.  RE: Linking error in program using CPLEX C++ API on Linux

    Posted Tue January 19, 2021 01:15 PM

    Dear Petr,

    This is my error link. I trying to test my algorithm with make and don't work.

    regards,

    Alex






    #DecisionOptimization
    #Support
    #SupportMigration


  • 4.  RE: Linking error in program using CPLEX C++ API on Linux

    Posted Wed January 20, 2021 12:21 PM

    If you compile one of the delivered examples using the makefile shipped with cplex, you could see that the compilation is done the following way:


    g++ -O0 -c -m64 -O -fPIC -fno-strict-aliasing -fexceptions -DNDEBUG -DIL_STD -I../../../include -I../../../../concert/include ../../../examples/src/cpp/fixcost1.cpp -o fixcost1.o

    g++ -O0 -m64 -O -fPIC -fno-strict-aliasing -fexceptions -DNDEBUG -DIL_STD -I../../../include -I../../../../concert/include -L../../../lib/x86-64_linux/static_pic -L../../../../concert/lib/x86-64_linux/static_pic -o fixcost1 fixcost1.o -lconcert -lilocplex -lcplex -lm -lpthread -ldl


    Note the the compiler is run twice: first to create object file, second to link. So I suggest to simply replace fixcost1 by name of your program, fix the paths in -I and -L options, and it should compile.


    The errors you see are due to the missing -lconcert -ilocplex and -lcplex. The other options are important too though. I suggest to start with the exact copy and then make changes if necessary.


    Regards, Petr






    #DecisionOptimization
    #Support
    #SupportMigration


  • 5.  RE: Linking error in program using CPLEX C++ API on Linux

    Posted Thu January 21, 2021 11:35 AM

    Hello Petr,


    Thanks for your help and ideas. I saw the examples files like makefile and I understand several components for my syntax, and also including additional libraries at last of my line like -ldl.


    This my line (work fine):

     g++ -std=gnu++11 -O0 -m64 -O -fPIC -fno-strict-aliasing -fexceptions -DNDEBUG -DIL_STD main.cpp vrp.cpp vrp.h -I/opt/ibm/ILOG/CPLEX_Studio129/cplex/include -I/opt/ibm/ILOG/CPLEX_Studio129/concert/include -L/opt/ibm/ILOG/CPLEX_Studio129/cplex/lib/x86-64_linux/static_pic -L/opt/ibm/ILOG/CPLEX_Studio129/concert/lib/x86-64_linux/static_pic -o hardprogram -lconcert -lilocplex -lcplex -lm -lpthread -ldl


    regards,

    Alex






    #DecisionOptimization
    #Support
    #SupportMigration