3

I have an error when I run my code at #include "ilcplex/ilocplex.h"

#include "ilcplex/ilocplex.h"
ILOSTLBEGIN



/*
 * 
 */
int main(int argc, char** argv) {
    IloEnv env;
    IloModel model(env);
    IloNumVarArray x(env);

    for(int i = 0; i < 3; i++) {
    std::stringstream name;
    name << "x_" << i;
    x.add(IloNumVar(
    env, 0, 1, IloNumVar::Float, name.str().c_str()
    ));
    }

    model.add(IloMaximize(env, x[0] + x[1] - x[2]));   //objective function

    IloRangeArray constraints(env);
    constraints.add( x[0] + 2 * x[1] - x[2] <= 2);
    constraints.add(-x[0] + x[1] + x[2] >= 1);
    model.add(constraints);

    //generating a file resuming
    IloCplex cplex(model);     //necessary to solve
    cplex.exportModel("model.lp");

    using std::cout; using std::cerr; using std::endl;
if(cplex.solve()) {
cout << "Cplex completed!" << endl;
cout << "Status: " << cplex.getStatus() << endl;
cout << "Obj value: " << cplex.getObjValue() << endl;
cout<< "x values : ";  
        for(int i=0;i<3;i++)
        {
           cout << cplex.getValue(x[i])<<endl;
        }

} else {
cerr << "Cplex error!" << endl;
cerr << "Status: " << cplex.getStatus() << endl;
cerr << "Cpx status: " << cplex.getCplexStatus() << endl;
}

    env.end();
    return 0;
}

the reported error is:

 c:\program 
 files\ibm\ilog\cplex_studio1271\concert\include\ilconcert\ilosys.h:262:21: 
 fatal error: generic.h: No such file or directory
 #include "generic.h"

In the project properties I have modified:

C++ compiler :

include directories [.../CPLEX/include and .../concert/include]

preprocessor [definitions IL_STD]

LINKER:

additional library directories [...cplex/lib/x64_windows_vs2015/stat_mda and ...concert/lib/x64_windows_vs2015/stat_mda]

additional dependencies [cplex1271.lib concert.lib ilocplex.lib]

Librarie [I have put all the libraries that were in the stat_mda folders and stat_mdd folders]

A.JO
  • 235
  • 4
  • 14
  • Are you trying to use the g++ compiler on Windows? If so, that is not supported (see the [detailed system requirements](http://www-01.ibm.com/support/docview.wss?uid=swg27019100)). A similar question was asked [here](https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014732333#77777777-0000-0000-0000-000014732835). – rkersh Oct 03 '17 at 15:49
  • Do you have an idea of what I should use instead of g++ ? @rkersh – A.JO Oct 03 '17 at 16:20
  • On Windows you'll need to use the Microsoft C and C++ compiler and linker (cl.exe). With CPLEX 12.7.1, this means you'll need the compiler that comes with Visual Studio 2013 or 2015. I believe you can download these for free via some type of "build tools" installer, but I'm not sure. You can also try using the free Visual Studio Express editions. – rkersh Oct 03 '17 at 16:38

0 Answers0