问题描述
我已尝试运行此代码:
#include "ortools/include/ortools/base/logging.h"
#include "ortools/include/ortools/constraint_solver/constraint_solver.h"
using namespace operations_research;
void runconstraintProgrammingExample() {
// Instantiate the solver.
Solver solver("ConstraintProgrammingExample");
const int64 numVals = 3;
// Define decision variables.
Intvar* const x = solver.MakeIntvar(0,numVals - 1,"x");
Intvar* const y = solver.MakeIntvar(0,"y");
Intvar* const z = solver.MakeIntvar(0,"z");
// Define constraints.
std::vector<Intvar*> xyvars = { x,y };
solver.AddConstraint(solver.MakeAllDifferent(xyvars));
// Create decision builder to search for solutions.
std::vector<Intvar*> allvars = { x,y,z };
DecisionBuilder* const db = solver.MakePhase(
allvars,Solver::CHOOSE_FirsT_UNBOUND,Solver::ASSIGN_MIN_VALUE);
bool has_result = solver.solve(db);
// Check that the problem has a solution.
if (has_result != true) {
//LOG(FATAL) << "The problem does not have a solution!";
}
int count = 0;
while (solver.NextSolution()) {
count++;
//LOG(INFO) << "Solution " << count << ":";
//LOG(INFO) << "x = " << x->Value()
// << " ; y = " << y->Value()
//<< " ; z = " << z->Value();
}
//LOG(INFO) << "Number of solutions: " << count;
//LOG(INFO) << "";
//LOG(INFO) << "Advanced usage:";
//LOG(INFO) << "Problem solved in " << solver.wall_time() << "ms";
}
// namespace operations_research
int main(int argc,char** argv) {
//google::InitGoogleLogging(argv[0]);
//FLAGS_logtostderr = 1;
runconstraintProgrammingExample();
return 0;
}
错误 LNK2019 未解析的外部符号“public: __thiscall operations_research::Solver::Solver(class std::basic_string
我尝试将来自 ortools 的包含文件放入项目的其他包含目录中,并且我还尝试将 ortools 库放入属性中的链接器输入中。还是没用。我还尝试将其修改为 x64 put 然后我得到 200 个左右的错误。我还能尝试什么?