Are Gurobi 9.1 and Visual Studio Code 1.51.1 compatible?
AnsweredI have an issue with linking the gurobi_c++ header file (Gurobi 9.1) in Visual Studio Code 1.51.1 to my main.cpp file. When I run the file, I am getting this error:
$ cd "/Users/ms/Dropbox/" && g++ main.cpp -o main && "/Users/ms/Dropbox/"main
Undefined symbols for architecture x86_64:
"GRBLinExpr::GRBLinExpr(GRBVar, double)", referenced from:
_main in main-ca8f94.o
"GRBLinExpr::operator+(GRBLinExpr const&)", referenced from:
_main in main-ca8f94.o
"GRBQuadExpr::GRBQuadExpr(GRBLinExpr)", referenced from:
_main in main-ca8f94.o
"GRBQuadExpr::GRBQuadExpr(double)", referenced from:
_main in main-ca8f94.o
"GRBEnv::GRBEnv(bool)", referenced from:
_main in main-ca8f94.o
"GRBEnv::~GRBEnv()", referenced from:
_main in main-ca8f94.o
"GRBModel::setObjective(GRBLinExpr, int)", referenced from:
_main in main-ca8f94.o
"GRBModel::addVar(double, double, double, char, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
_main in main-ca8f94.o
"GRBModel::update()", referenced from:
_main in main-ca8f94.o
"GRBModel::optimize()", referenced from:
_main in main-ca8f94.o
"GRBModel::addConstr(GRBTempConstr const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
_main in main-ca8f94.o
"GRBModel::GRBModel(GRBEnv const&)", referenced from:
_main in main-ca8f94.o
"GRBModel::~GRBModel()", referenced from:
_main in main-ca8f94.o
"GRBVar::get(GRB_DoubleAttr) const", referenced from:
_main in main-ca8f94.o
"GRBVar::get(GRB_StringAttr) const", referenced from:
_main in main-ca8f94.o
"GRBModel::get(GRB_DoubleAttr) const", referenced from:
_main in main-ca8f94.o
"operator>=(GRBQuadExpr, GRBQuadExpr)", referenced from:
_main in main-ca8f94.o
"operator<=(GRBQuadExpr, GRBQuadExpr)", referenced from:
_main in main-ca8f94.o
"operator*(double, GRBVar)", referenced from:
_main in main-ca8f94.o
"operator+(GRBVar, GRBVar)", referenced from:
_main in main-ca8f94.o
"operator+(GRBLinExpr const&, GRBLinExpr const&)", referenced from:
_main in main-ca8f94.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
$
I have already defined the required environment variables (GRB_LICENSE_FILE, GUROBI_HOME, GUROBI_INC_DIRECTORY, LIBRARY_PATH).
0
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
Hi Monique,
Visual Studio Code cannot be incompatible with Gurobi because it is just a coding environment. The errors you are seeing are coming from your compiler, which is clang. You need to specify the Gurobi C++ libraries and headers to successfully compile a C++ project that uses Gurobi.
Please refer to these articles for further information on the topic:
- How do I resolve "undefined reference" errors while linking Gurobi in C++?
- How do I use CMake to build Gurobi C/C++ projects?
Cheers,
Matthias0
Post is closed for comments.
Comments
2 comments