当我在MAC OSX上使用带有matlab的cplex优化工作室来解决线性编程问题时,我遇到了严重的问题。我试着运行一个mex文件,所以我做了
mex -I/...../Applications/IBM/ILOG/CPLEX_Studio1271/cplex/include -I/....../Applications/IBM/ILOG/CPLEX_Studio1271/concert/include -L/......../Applications/IBM/ILOG/CPLEX_Studio1271/cplex/lib/x86-64_osx -lcplex lp_cplex_mex.cpp
所以在上面的代码中我调用.h header
并且库在.cpp
文件中使用它们,我得到的第一个错误是:
...concert/include/ilconcert/ilosys.h:391:10: fatal
error: 'iostream.h' file not found
所以我转到这一行并将<iostream.h>
更改为<iostream>
,然后它可以知道该文件,但在下一次编译中我再次收到20多个错误,例如:
In file included from /.../Desktop/example/lp_cplex_mex.cpp:22:
In file included from...
并且
unknown type name 'ostream'; did you mean 'std::ostream'?
virtual void print(ILOSTD(ostream)& out) const;
~~~~~~~^~~~~~~~
std::ostream
我澄清说:
此外,如果我尝试在ostream
之前更改每个文件std::ostream
,我将无法获得任何内容,因为Cplex Library
包含数千行。另一方面,我安装了最后一版的cplex和Xcode?!
我希望您对这个问题提出建议,因为我找到的最大解决方案是<iostream.h>
更改为<iostream>
,但正如我所说,这不是一个完美的解决方案,因为我只能在我的C ++ Mex中进行更改-file不在Cplex中!
修改
现在我按照你的说法做了,我在#define IL_STD
编译文件的头部添加了.cpp
,然后我收到了新的错误:
Undefined symbols for architecture x86_64:
"IloNumExpr::IloNumExpr(IloNumExprArg)", referenced from:
_main in lp_cplex_mex.o
"IloNumArray::IloNumArray(IloEnv, long)", referenced from:
_main in lp_cplex_mex.o
"IloAddNumVar::~IloAddNumVar()", referenced from:
_main in lp_cplex_mex.o
"IloObjective::setLinearCoef(IloNumVar, double)", referenced from:
_main in lp_cplex_mex.o
"IloObjective::IloObjective(IloEnv, double, IloObjective::Sense, char
const*)", referenced from:
_main in lp_cplex_mex.o
.......
.......
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)