undefined reference
AnsweredHi
I am having a problem when trying to use the Gurobi library in C++. Specifically, I am getting "undefined reference" errors during the linking process. I have added the necessary lines to my bashrc and am compiling my test file with the command
g++ test.cpp -o main -I../../../../software/gurobi1000/linux64/include -L../../../../software/gurobi1000/linux64/lib
I have attempted to research the issue, and have come across the following link by Gurobi support:
https://support.gurobi.com/hc/en-us/articles/360039093112-How-do-I-resolve-undefined-reference-errors-while-linking-Gurobi-in-C-.
I have verified that the libgurobi_c++.a file is present in the lib directory, however, the issue remains unresolved.
I would appreciate any help in resolving this issue.

-
Official comment
This post is more than two 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 try Gurobot, our chatbot interface offering instant, expert-level support. -
Hi Samira,
It looks like you have to recompile the library: How do I resolve "undefined reference" errors while linking Gurobi in C++?
Cheers,
David0 -
Also, it seems that you have forgotten to import the library. Just add \(\texttt{-lgurobi100 -lgurobi_c++}\).
Cheers,
David0 -
I have been able to successfully compile utilizing:
g++ test.cpp -o main -I../../../../software/gurobi1000/linux64/include -L../../../../software/gurobi1000/linux64/lib -lgurobi100 -lgurobi_c++
Thanks!0
Post is closed for comments.
Comments
4 comments