Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Linking CPLEX to Eclipse IDE for C/C++ (Mars.2) on Mac OS X El Capitan

  • 1.  Linking CPLEX to Eclipse IDE for C/C++ (Mars.2) on Mac OS X El Capitan

    Posted Sun June 26, 2016 05:12 AM

    Originally posted by: Soheilmn


    Hi,

    I have recently switched from Windows to Mac OS X El Capitan (Version 10.11.5) and have installed CPLEX 12.5.1 via the terminal window using ./cplex_studio1251.osx.bin command. The installation has gone smoothly with no error/warning messages.  Both Eclipse and CPLEX are 64bit versions. (I can spot the folder IBM/ILOG/CPLEX_Studio1251/cplex/lib/x86-64_osx, so I assume it is 64bit version.)

    In Eclipse, I have introduced the header paths to GCC C++ Compiler, which are 

    1. IBM/ILOG/CPLEX_Studio1251/concert/include, and
    2. IBM/ILOG/CPLEX_Studio1251/concert/include. 

    Also, I have set the linker search paths for the GCC C++ Linker as

    1. IBM/ILOG/CPLEX_Studio1251/concert/lib/x86-64_osx/static_pic, and
    2. IBM/ILOG/CPLEX_Studio1251/concert/lib/x86-64_osx/static_pic.

    Finally, I have set one miscellaneous flags, which is "-DIL_STD."

    To test my installation, I have written the following simple code.

    ------------------------------------------------------------------------------------------------

    #include <iostream>

    #include <ilcplex/ilocplex.h>

     

    using namespace std;

     

    ILOSTLBEGIN

     

    int main() {

    IloEnv env;

    env.out() << "IBM CPLEX functions properly." << endl;

    return 0;

    }

    ------------------------------------------------------------------------------------------------

     

    However, I get a long error message (rooting from C++ linker, I guess), which is basically complaining about not finding the symbols for architecture x86_64. (I have attached an RTF file containing the build log file.)

     

    ------------------------------------------

    Undefined symbols for architecture x86_64:

      "IloEnv::IloEnv()", referenced from:

          _main in Test1-6472a6.o

    ld: symbol(s) not found for architecture x86_64

    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    -------------------------------------------

    While the error seems to be related to having different versions of CPLEX, Eclipse, and OSX, I don't understand the issue because I am sure that the OS is indeed 64bit, Eclipse offers only 64bit version of its IDEs for Mac, and CPLEX is also available in 64bit version for Mac users (and as I explained, there are only x86_64 folders in related library folders in my CPLEX installation).

    Has anyone run into similar problem?  I highly appreciate any help.   


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Linking CPLEX to Eclipse IDE for C/C++ (Mars.2) on Mac OS X

    Posted Mon June 27, 2016 03:24 AM

    Please search this Forum for similar issues. Problems like this have been discussed several times.

    The easiest thing is to go to /IBM/ILOG/CPLEX_Studio1251/cplex/examples/x86-64_osx/static_pic and type 'make blend'. This will build the C++ example blend.cpp. It will also dump the command lines it is using for this build. Then make sure the compiler and linker command lines used via Eclipse are the same as those printed there.

    One obvious issue with the command lines you are currently using is that the '-c' flag seems to be missing for the compilation step. That is why the compiler attempts to link (and does not find the libs) while it is only supposed to compile.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Linking CPLEX to Eclipse IDE for C/C++ (Mars.2) on Mac OS X

    Posted Tue June 28, 2016 04:26 AM

    Originally posted by: Soheilmn


    Hi Daneil,

     

    Thanks for the reply.  I followed your suggestion, checked other posts, and found the solution after reading few posts.  Below, I would like to summarize what I did to resolve the issue. Hope it provides others a very clear and straightforward approach. The thing is the default "makefile" does produce the same error: ld: symbol(s) not found for architecture x86_64. This can be resolved specifically by adding the flag "-stdlib=libstdc++" to both compiler and the linker (as you have mentioned in your posts).      

     

    The following are the information regarding my installation:

     

    CPLEX version: 12.5.1  (This version comes in x64 architecture.)

    OS: Mac OS X El Capitan 10.11.5

    IDE: Eclipse IDE for C/C++ Developers, Version: Mars.2 Release (4.5.2.20160218-0600), Compiler: g++

     

    I have installed CPLEX in the default path:   /Users/soheilmn/Applications/IBM/ILOG/CPLEX_Studio1251. To set up Eclipse to work with CPLEX, one needs to point to Project->Properties in Eclipse and set a few parameters as follows. 

     

     

     

     

     

      


    #DecisionOptimization