Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Cplex Build in Visual Studio Code

Archive User

Archive UserTue January 09, 2018 10:08 AM

  • 1.  Cplex Build in Visual Studio Code

    Posted Tue January 09, 2018 10:08 AM

    Originally posted by: Anjikum


    Hello,

     

    I am trying to build CPLEX 12.7 trial version with Visual Studio Code installed in Windows. While doing so, I am not successful at build with cplex to sample project. 

     

    Can I build CPLEX with Visual studio Code?

     

    Thanks in Advance.

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Cplex Build in Visual Studio Code

    Posted Tue January 09, 2018 10:20 AM

    What exactly is the problem you are facing? How are you trying to compile/link things from Visual Studio Code?

    Also, CPLEX should not be different from any other 3rd party library, so you should probably check with a Visual Studio Code forum how to include 3rd party software in builds in general.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Cplex Build in Visual Studio Code

    Posted Tue July 17, 2018 03:13 AM

    Originally posted by: diegorossit


    I am facing the same problem. It would be nice to get a detailed reply.

    It seems it cannot find the ilcplex/ilocplex.h. This is what I get:

    Executing task: g++ -g main.cpp <

    main.cpp:7:10: fatal error: ilcplex/ilocplex.h: No such file or directory
     #include "ilcplex/ilocplex.h"
              ^~~~~~~~~~~~~~~~~~~~
    compilation terminated.
    The terminal process terminated with exit code: 1

    Terminal will be reused by tasks, press any key to close it.

     

    This is my c_cpp_properties.json file

     

    {
    "configurations": [
    {
    "name": "Linux",
    "includePath": [
    "${workspaceFolder}/**",
    "/opt/ibm/ILOG/CPLEX_Studio128/cplex/include",
    "/opt/ibm/ILOG/CPLEX_Studio128/concert/include",
    "/usr/include/linux",
    "/usr/include/c++/7",
    "/usr/include/x86_64-linux-gnu/c++/7",
    "/usr/include/c++/7/backward",
    "/usr/lib/gcc/x86_64-linux-gnu/7/include",
    "/usr/local/include",
    "/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed",
    "/usr/include/x86_64-linux-gnu",
    "/usr/include"
    ],
    "defines": [],
    "compilerPath": "/usr/bin/gcc",
    "cStandard": "c11",
    "cppStandard": "c++17",
    "intelliSenseMode": "clang-x64",
    "browse": {
    "path": [
    "/opt/ibm/ILOG/CPLEX_Studio128/cplex/include",
    "/opt/ibm/ILOG/CPLEX_Studio128/concert/include"
    ],
    "limitSymbolsToIncludedHeaders": true,
    "databaseFilename": ""
    }
    }
    ],
    "version": 4
    }

    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Cplex Build in Visual Studio Code

    Posted Tue July 17, 2018 04:16 AM

    Can you paste the compiler command line the tool actually uses?

    One thing that seems to be definitely missing is -DIL_STD (this will produce errors once you get the inclusion working correctly).

    The usual way to do things is

    - go to $CPLEX/cplex/examples/x86-64_linux/static_pic

    - run 'make blend'

    This compiles and links the program blend.cpp. It shows all commands that are executed. From this you should be able to pick up all the flags that are required for compiling and linking an application that uses CPLEX. Then configure your 3rd party tool with these settings.


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Cplex Build in Visual Studio Code

    Posted Tue July 17, 2018 04:37 AM

    BTW, assuming your output is complete, the compiler command line is just

    g++ -g main.cpp

    No include paths, nothing else. You should probably check with the maintainers of this tool how to correctly configure additional include paths etc.


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Cplex Build in Visual Studio Code

    Posted Tue March 26, 2019 04:14 AM

    Originally posted by: beyondzhao


    Hi, diegorossit,

    I got the same problem with you. And I am not familiar with the programming of C++. Have you solved this problem? I would appreciate if you can give me some advice.


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Cplex Build in Visual Studio Code

    Posted Tue March 26, 2019 10:01 AM

    Did you try the things I suggested? In particular, did you run 'make blend' as instructed and setup your development environment so that it produces the same compiler and linker command lines?


    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: Cplex Build in Visual Studio Code

    Posted Wed March 27, 2019 11:19 PM

    Originally posted by: beyondzhao


    I have run the command "make blend" and it succeeded. But my own .cpp file still not work.
    And what you say about "set development environment" is writting a make file for .cpp file? Or something else? I will appreciate your help if you can explain specifically because that I am not familiar with C++.


    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: Cplex Build in Visual Studio Code

    Posted Thu March 28, 2019 02:37 AM

    When you run 'make blend' then you will see a lot of output that contains the compiler and linker flags. Since you asked in a thread titled "Visual Studio Code" I was assuming that you are using Visual Studio Code as development environment. Each development environment has ways to set compiler and linker flags for a project. You have to find these and add the required flags there. If none of this makes any sense to you then you probably first should make yourself familiar with C++ and how to compile and link C++ applications with 3rd party libraries. This is unrelated to CPLEX and I would guess that there are tutorials for this.

    If you use a development environment then you don't have to explicitly create a makefile. However, if you want to work with a makefile then you can just copy the makefile that comes with CPLEX, replace 'blend' with your own file and be done. Note that on Windows there is no makefile for C++ projects, instead there are project configurations for Microsoft Visual Studio. If you are on Windows you may also want to read the file c_cpp.html that can be found in the installation directory. It explains how to setup projects for Microsoft Visual Studio. Things may be similar for Visual Studio Code.


    #CPLEXOptimizers
    #DecisionOptimization


  • 10.  Re: Cplex Build in Visual Studio Code

    Posted Thu March 28, 2019 07:50 AM

    Originally posted by: beyondzhao


    OK, I'll learn more about C++. Thank you very much for your help.


    #CPLEXOptimizers
    #DecisionOptimization


  • 11.  Re: Cplex Build in Visual Studio Code

    Posted Tue April 02, 2019 09:05 AM

    Originally posted by: beyondzhao


    Hi,

    I installed codeblocks on my ubuntn system and set the configuration according to the website http://www-01.ibm.com/support/docview.wss?uid=swg21449771.
    In fact what I want to use is cpoptimizer, and in the step 4 ,5 I also added the path of cpoptimizer. But when I run my code in codeblocks, it still get the error "undefined reference to IloCP". Do you have some experience about using CP or know how to set the compile and linker options of CP?


    #CPLEXOptimizers
    #DecisionOptimization


  • 12.  Re: Cplex Build in Visual Studio Code

    Posted Wed April 03, 2019 03:10 AM

    You may want to ask this question in one of the forums related to CP optimizer here.

    Also include the exact error message as well as the compiler and linker command lines used by codeblocks.


    #CPLEXOptimizers
    #DecisionOptimization


  • 13.  Re: Cplex Build in Visual Studio Code

    Posted Wed March 27, 2019 12:23 PM

    Originally posted by: diegorossit


    Hi! I am sorry I didn't solve it....... so nowadays I used Visual Studio Express for Desktop in Windows and Codeblocks in Linux for using CPLEX.

    I hope you are more skilled than me and you can solve it!

     

    Good luck!

     

    Diego


    #CPLEXOptimizers
    #DecisionOptimization


  • 14.  Re: Cplex Build in Visual Studio Code

    Posted Wed March 27, 2019 11:07 PM

    Originally posted by: beyondzhao


    Thank you all the same.


    #CPLEXOptimizers
    #DecisionOptimization


  • 15.  Re: Cplex Build in Visual Studio Code

    Posted Tue April 02, 2019 09:04 AM

    Originally posted by: beyondzhao


    Hi,

    I installed codeblocks on my ubuntn system and set the configuration according to the website http://www-01.ibm.com/support/docview.wss?uid=swg21449771.
    In fact what I want to use is cpoptimizer, and in the step 4 ,5 I also added the path of cpoptimizer. But when I run my code in codeblocks, it still get the error "undefined reference to IloCP". Do you have some experience about using CP or same problems like this?
     


    #CPLEXOptimizers
    #DecisionOptimization