Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Running CPLEX from GCC?

    Posted Mon November 26, 2012 06:20 PM

    Originally posted by: SystemAdmin


    Hello,

    I'm trying to run the C++ examples on Linux, but I'm getting a lot of errors. Does anyone have a clue of where can I find a running example that compiles on GCC?

    I try to compile the warehouse.cpp example. First, I had to remove a lot of ".h" from the includes (e.g., the iostream.h include). Now I'm getting a lot of errors

    My goal is to run a model using static linked libraries. Any ideas?

    The erros that I'm getting:

    Thank you!

    /usr/include/c++/4.6/backward/backward_warning.h|33|warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated. -Wcpp|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilosys.h|598|error: ‘ostream’ has not been declared|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilosys.h|614|error: ‘ostream’ has not been declared|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilosys.h|640|error: ‘ostream’ does not name a type|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilosys.h|646|error: ‘ostream’ does not name a type|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilosys.h|675|error: ‘ostringstream’ was not declared in this scope|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilosys.h|675|note: suggested alternative:|
    /usr/include/c++/4.6/iosfwd|150|note: ‘std::ostringstream’|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilosys.h|675|error: ‘stream’ was not declared in this scope|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h||In member function ‘void* IloMemoryManager::alloc(size_t) const’:|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|113|error: ‘cerr’ was not declared in this scope|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|113|note: suggested alternative:|
    /usr/include/c++/4.6/iostream|63|note: ‘std::cerr’|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|113|error: ‘endl’ was not declared in this scope|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|113|note: suggested alternative:|
    /usr/include/c++/4.6/ostream|543|note: ‘std::endl’|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h||In member function ‘void IloMemoryManager::free(void*, size_t) const’:|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|117|error: ‘cerr’ was not declared in this scope|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|117|note: suggested alternative:|
    /usr/include/c++/4.6/iostream|63|note: ‘std::cerr’|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|117|error: ‘endl’ was not declared in this scope|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|117|note: suggested alternative:|
    /usr/include/c++/4.6/ostream|543|note: ‘std::endl’|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h||In member function ‘void IloMemoryManager::saveValue(void**) const’:|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|121|error: ‘cerr’ was not declared in this scope|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|121|note: suggested alternative:|
    /usr/include/c++/4.6/iostream|63|note: ‘std::cerr’|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|121|error: ‘endl’ was not declared in this scope|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|121|note: suggested alternative:|
    /usr/include/c++/4.6/ostream|543|note: ‘std::endl’|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h||In member function ‘void IloMemoryManager::saveValue(IloInt*) const’:|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|125|error: ‘cerr’ was not declared in this scope|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|125|note: suggested alternative:|
    /usr/include/c++/4.6/iostream|63|note: ‘std::cerr’|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|125|error: ‘endl’ was not declared in this scope|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|125|note: suggested alternative:|
    /usr/include/c++/4.6/ostream|543|note: ‘std::endl’|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h||In member function ‘void IloMemoryManager::saveValue(IloNum*) const’:|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|129|error: ‘cerr’ was not declared in this scope|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|129|note: suggested alternative:|
    /usr/include/c++/4.6/iostream|63|note: ‘std::cerr’|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|129|error: ‘endl’ was not declared in this scope|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|129|note: suggested alternative:|
    /usr/include/c++/4.6/ostream|543|note: ‘std::endl’|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h||In function ‘void* operator new(size_t, const IloMemoryManager&)’:|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|136|error: ‘cerr’ was not declared in this scope|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|136|note: suggested alternative:|
    /usr/include/c++/4.6/iostream|63|note: ‘std::cerr’|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|136|error: ‘endl’ was not declared in this scope|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|136|note: suggested alternative:|
    /usr/include/c++/4.6/ostream|543|note: ‘std::endl’|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h||In function ‘void* operator new [](size_t, const IloMemoryManager&)’:|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|146|error: ‘cerr’ was not declared in this scope|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|146|note: suggested alternative:|
    /usr/include/c++/4.6/iostream|63|note: ‘std::cerr’|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|146|error: ‘endl’ was not declared in this scope|
    /home/...../Test1/opl_interfaces/cpp/src/ilconcert/ilomemmgr.h|146|note: suggested alternative:|
    /usr/include/c++/4.6/ostream|543|note: ‘std::endl’|
    More errors follow but not being shown.

    Edit the max errors limit in compiler options...

    === Build finished: 50 errors, 1 warnings ===


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Running CPLEX from GCC?

    Posted Tue November 27, 2012 12:53 AM

    Originally posted by: Laci Ladanyi


    What do you mean by "First, I had to remove a lot of ".h" from the includes (e.g., the iostream.h include)." ? Those headers are there for good reasons, for example, iostream.h defines ostream, cerr, endl, etc. Did you have errors when those includes were there? If so, what were they?

    --Laci
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Running CPLEX from GCC?

    Posted Tue November 27, 2012 12:56 AM

    Originally posted by: Laci Ladanyi


    Oh, I just realized that you have removed only the ".h"... In that case the only thing I can think of is that the your g++ (v4.6) is not quite compatible with the g++ cplex is built with. Still, I'd like to know what were the errors you got before removing the .h from the include statements.

    --Laci
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Running CPLEX from GCC?

    Posted Tue November 27, 2012 01:03 AM

    Originally posted by: SystemAdmin


    Hello, thank you for answering!

    The error was quite straighforward: "iostream.h not found" or something alike.

    I agree with you, it is a gcc version issue. Is there anyway to bypass it?

    I'll need to compile it into a shared machine that I cannot just reinstall gcc...

    Thank you!
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Running CPLEX from GCC?

    Posted Tue November 27, 2012 01:21 AM

    Originally posted by: SystemAdmin


    The header files are designed to be backward compatible with very old versions of C++ compilers. For modern g++ you have to define some preprocessor directives. This is why CPLEX comes with examples and an example makefile. Please try the following
    cd /path/to/cos/cplex/x86-64_sles10_4.1/static_pic
    make ilolpex1
    

    This will compile the ilolpex1 example (first compiling an object file and then linking the executable). Moreover, the executed commands will be printed. From those you can derive the flags you need to define when compiling/linking.
    One important flag to use is -DIL_STD. This should fix all the header file problems you mentioned.
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Running CPLEX from GCC?

    Posted Tue November 27, 2012 02:01 AM

    Originally posted by: SystemAdmin


    Ow, it seems that is working! Thanks!

    To run the file, I did

    make execute_cpp ilolpex
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Running CPLEX from GCC?

    Posted Tue November 27, 2012 02:10 AM

    Originally posted by: SystemAdmin


    The 'execute_cpp' target first builds all the C++ examples (so the additional 'ilolpex1' target is redundant) and then runs all of them.
    Unfortunately, there is no target to run a single example but it is easy to pick the required command from the Makefile.
    #CPLEXOptimizers
    #DecisionOptimization