Question about a compilation error in a file where I've written #include <gurobi_c++.h>.
AnsweredI'm having trouble with a compilation error in a file where I've written #include <gurobi_c++.h>. Below is the result of compiling mip1_c++.cpp.
/opt/gurobi1103/linux64/examples/c++$ make mip1_c++
g++ mip1_c++.cpp -o mip1_c++
mip1_c++.cpp:11:10: fatal error: gurobi_c++.h: No such file or directory
11 | #include "gurobi_c++.h"
| ^~~~~~~~~~~~~~
When I ran gurobi_cl in my home directory (~/), the following was displayed:
Set parameter Username
Set parameter LogFile to value "gurobi.log"
Using license file /home/whill/gurobi.lic
Academic license - for non-commercial use only - expires 2025-10-24
Usage: gurobi_cl [--command]* [param=value]* filename
Type 'gurobi_cl --help' for more information.
I wrote the following at the end of the bashrc file (~/.bashrc) in my home directory, as per the gurobi manual.
export GRB_LICENSE_FILE=~/gurobi.lic
export GUROBI_HOME="/opt/gurobi1103/linux64"
export PATH="${PATH}:${GUROBI_HOME}/bin"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${GUROBI_HOME}/lib"
Furthermore, I don't understand the note in the "building and running the examples" section at the URL below: A C++ program that uses Gurobi must link in both the Gurobi C++ library libgurobi_c++.a and the Gurobi C library libgurobi100.so."
What exactly should I do? Is it related to this compilation error?
I would like to be able to use gurobi_c++.h!!
I would appreciate it if you could let me advice.
-
Hi,
Can you try the following command in your terminal?
g++ -o mip1_c++.cpp -o mip1_c++ -I/opt/gurobi1103/linux64/include/ -L/opt/gurobi1103/linux64/lib -lgurobi_c++ -lgurobi110The part in bold is linking the Gurobi C++ library and the Gurobi C library
This should produce an executable called
mip1_c++which you can then run- Riley
0 -
Thank you for your kind advice!!
I ran the following command and it worked fine!!g++ -o mip1_c++ mip1_c++.cpp -I/opt/gurobi1103/linux64/include/ -L/opt/gurobi1103/linux64/lib -lgurobi_c++ -lgurobi110
Thank you for your continued support.
0
Please sign in to leave a comment.
Comments
2 comments