Skip to main content

cannot find -lgurobi_c++ , cannot find -lgurobi81 linking error

Answered

Comments

13 comments

  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    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
  • Angelos Tsoukalas
    Gurobi-versary
    Conversationalist
    First Question

    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
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    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
  • Angelos Tsoukalas
    Gurobi-versary
    Conversationalist
    First Question

    You can see the output below. It is the absolute path.  

    0
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Could you try moving the variable $(CPPLIB) after the \(\texttt{-o}\) argument, i.e.,

    $(CPP) $(CXXFLAGS) ... -o matching $$bla $(CPPLIB) ...
    0
  • Angelos Tsoukalas
    Gurobi-versary
    Conversationalist
    First Question

    This does not seem to work. Besides, it worked like this on the other computer

    0
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    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
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    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
  • Angelos Tsoukalas
    Gurobi-versary
    Conversationalist
    First Question

    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
  • Angelos Tsoukalas
    Gurobi-versary
    Conversationalist
    First Question

    And this is what is in the /lib directory. 

    0
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    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
  • Angelos Tsoukalas
    Gurobi-versary
    Conversationalist
    First Question

    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
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Good to hear that it works now!

    0

Please sign in to leave a comment.