cannot find -lgurobi_c++ , cannot find -lgurobi81 linking error
AnsweredHi,
I am trying to run my code (developed on a MAC) on a Linux machine. I am getting a linking error
/usr/bin/ld: cannot find -lgurobi_c++
/usr/bin/ld: cannot find -lgurobi81
The Gurobi examples now run, although I had to recompile Gurobi and manually move the re-compiled library file in /lib.
Not sure what is the issue. Here is a screenshot of the first few lines of my Makefile. This Makefile (with adjusted paths) works on my MAC and the CPPLIB path is identical with the one in the Makefile of the examples that successfully compiles.
Any help would be highly appreciated.
Best,
Angelos
-
Hi Angelos,
How are you? It's been quite some time since we last spoke :)
Regarding your question, just for my understanding, the examples coming with Gurobi compile on your Linux machine, but when you use the screenshotted Makefile, you get the error \(\texttt{cannot find ...}\), correct?
You could try to run
ld /home/angelos/tsouk/gurobi811/linux64/lib/libgurobi_c++.a -lgurobi_c++ --verbose
to see whether you get the output
attempt to open /home/angelos/tsouk/gurobi811/linux64/lib/libgurobi_c++.a succeeded
as a first step. The error usually means that the path is wrong or that the library file is not present at the provided path.
The Gurobi examples now run, although I had to recompile Gurobi and manually move the re-compiled library file in /lib.
Depending on the compiler, it might be necessary to recompile the code so don't worry about this.
Best regards,
Jaromił0 -
Hi Jarek,
long time indeed! All good on my side. Thanks for offering to help. I run your command and I get a long output. Below is (what I think is) the relevant part. Note that gurobi is not in /usr/local/...., not sure why it searches there.
Best,
Angelos
ld: mode elf_x86_64
attempt to open /home/angelos/tsouk/gurobi811/linux64/lib/libgurobi_c++.a succeeded
/home/angelos/tsouk/gurobi811/linux64/lib/libgurobi_c++.a
attempt to open /usr/local/lib/x86_64-linux-gnu/libgurobi_c++.so failed
attempt to open /usr/local/lib/x86_64-linux-gnu/libgurobi_c++.a failed
attempt to open /lib/x86_64-linux-gnu/libgurobi_c++.so failed
attempt to open /lib/x86_64-linux-gnu/libgurobi_c++.a failed
attempt to open /usr/lib/x86_64-linux-gnu/libgurobi_c++.so failed
attempt to open /usr/lib/x86_64-linux-gnu/libgurobi_c++.a failed
attempt to open /usr/lib/x86_64-linux-gnu64/libgurobi_c++.so failed
attempt to open /usr/lib/x86_64-linux-gnu64/libgurobi_c++.a failed
attempt to open /usr/local/lib64/libgurobi_c++.so failed
attempt to open /usr/local/lib64/libgurobi_c++.a failed
attempt to open /lib64/libgurobi_c++.so failed
attempt to open /lib64/libgurobi_c++.a failed
attempt to open /usr/lib64/libgurobi_c++.so failed
attempt to open /usr/lib64/libgurobi_c++.a failed
attempt to open /usr/local/lib/libgurobi_c++.so failed
attempt to open /usr/local/lib/libgurobi_c++.a failed
attempt to open /lib/libgurobi_c++.so failed
attempt to open /lib/libgurobi_c++.a failed
attempt to open /usr/lib/libgurobi_c++.so failed
attempt to open /usr/lib/libgurobi_c++.a failed
attempt to open /usr/x86_64-linux-gnu/lib64/libgurobi_c++.so failed
attempt to open /usr/x86_64-linux-gnu/lib64/libgurobi_c++.a failed
attempt to open /usr/x86_64-linux-gnu/lib/libgurobi_c++.so failed
attempt to open /usr/x86_64-linux-gnu/lib/libgurobi_c++.a failed
ld: cannot find -lgurobi_c++
0 -
The library is found successfully
attempt to open /home/angelos/tsouk/gurobi811/linux64/lib/libgurobi_c++.a succeeded
The other attempts is just \(\texttt{ld}\) scanning through the standard paths to search for the requested library.
Could you try executing the make command with more verbose output to try to pin down the error. This should work via
make SHELL='sh -x'
It looks like the path /home/angelos/tsouk/gurobi811/linux64/lib/ is not correctly recognized by the make command. This is strange, because you stated that the Gurobi examples can be compiled with the same path. Is it the full absolute path or is you Linux system connected to a network file system? In this case the full absolute path would be something similar to /nfs/home/angelos/tsouk/gurobi811/linux64/lib/.
0 -
You can see the output below. It is the absolute path.
0 -
Could you try moving the variable $(CPPLIB) after the \(\texttt{-o}\) argument, i.e.,
$(CPP) $(CXXFLAGS) ... -o matching $$bla $(CPPLIB) ...
0 -
This does not seem to work. Besides, it worked like this on the other computer
0 -
Could you double check whether the files are indeed at /home/angelos/tsouk/gurobi811/linux64/lib? It is very strange that ld cannot find them if that's the absolute path.
0 -
Just to double check, you are able to compile the C++ examples by calling, e.g., \(\texttt{make mip1_c++}\) in /home/angelos/tsouk/gurobi811/linux64/examples/build?
0 -
Yes. Screenshot below. In case I messed something up, let me repeat I have done the following
cd /opt/gurobi751/linux64/src/build/ make
cp libgurobi_c++.a ../../lib/
as in the asnwer of Grisotto here: https://stackoverflow.com/questions/46779850/cannot-compile-gurobi-examples-in-version-7-5-1
0 -
And this is what is in the /lib directory.
0 -
In your command there is an empty \(\texttt{-I}\) preceding the \(\texttt{-L...gurobi}\) libraries. It seems like the variable $(INCIPOPT) is empty. Could you try removing it?
0 -
Yes, this works. Thanks a lot! I deleted the INCIPOPT as I am not using IPOPT anymore, but did not realize I did not remove it from the command. Apologies for the many back and forths.
0 -
Good to hear that it works now!
0
Please sign in to leave a comment.
Comments
13 comments