Decision Optimization

Decision Optimization

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

 View Only
  • 1.  MSVC setjmp redefinition (see inside attachment the content)

    Posted Mon October 18, 2021 03:29 PM
    Edited by System Admin Fri January 20, 2023 04:42 PM
    Hello

    I am trying to use for first time cplex with Microsoft Visual Studio. I have followed the installation process on this link (I have also included the cp.lib)
    cplex config for MSVC


    I have tried the following example included in the documentation

    #include <ilcp/cp.h>
    
    int main(int, const char* []) {
        using namespace std;
        IloEnv env;
        try {
            IloModel model(env);
            IloIntVar x(env, 5, 12, "x");
            IloIntVar y(env, 2, 17, "y");
            model.add(x + y == 17);
            model.add(x - y == 5);
            IloCP cp(model);
            cp.propagate();
            cp.out() << std::endl << "Propagate:" << std::endl;
            cp.out() << "x in " << cp.domain(x) << std::endl;
            cp.out() << "y in " << cp.domain(y) << std::endl << std::endl;
            if (cp.solve()) {
                cp.out() << std::endl << "Solution:" << std::endl;
                cp.out() << "x = " << cp.getValue(x) << std::endl;
                cp.out() << "y = " << cp.getValue(y) << std::endl;
            }
        }
        catch (IloException& ex) {
            env.out() << "Error: " << ex << std::endl;
        }
        env.end();
        return 0;
    }

    However I am getting a redefintion error of "longjmp" between the MSVC library VC\Tools\MSVC\14.29.30133\include\setjmp.h and cplex ilosys.h

    What am I doing wrong?

    Thanks in advance


    ------------------------------
    javier rodrigo
    ------------------------------
    #DecisionOptimization


  • 2.  RE: MSVC setjmp redefinition (see inside attachment the content)

    Posted Tue October 19, 2021 09:31 AM
    Hello,
    the compilation flags may differ depending on the versions of CPLEX_Studio and of the compiler.
    The simplest thing to do: open the properties window of the MSVC project examples.cpp.sln of your installation of CPLEX Studio, and copy the different parameters for your new project.
    You can find the file examples.cpp.sln in the cpoptimizer/examples directory.
    Regards,
    ol

    ------------------------------
    Olivier Lhomme
    ------------------------------



  • 3.  RE: MSVC setjmp redefinition (see inside attachment the content)

    Posted Tue October 19, 2021 02:46 PM
    Thanks. I followed your recommedation and I managed to run the cplex examples without problems. However, if I copy all the properties on my project it does not work. I am sure is my lack of knowledge on compile and linker directives. It does no matter as I can copy the working project and just modify the source code with mine.

    One question, what's the difference between the stat_mda and stat_mdd folders inside the lib folder?

    Many thanks

    ------------------------------
    javier rodrigo
    ------------------------------



  • 4.  RE: MSVC setjmp redefinition (see inside attachment the content)

    Posted Wed October 20, 2021 11:59 AM
    autoanswer:

    The Concert Technology libraries are delivered in two static formats for Microsoft Visual C++ 14 (x64_windows_msvc14), so that a static executable can be linked with msvcrt.lib (multi-threaded DLL) or msvcrtd.lib (multi-threaded DLL debug)

    I imagine stat_mdd for debug

    ------------------------------
    javier rodrigo
    ------------------------------