How to install gurobi in C++ Interface



  • Official comment
    Dan Jeffrey

    Hello! You are missing the link instruction to the compiler.

    On Windows, the supported compiler is Visual C++. The "happy path" for Windows developers is to use Microsoft Visual Studio. There is a free "Community Edition" of Visual Studio that has no limitations for non-commercial use (you should read their license agreement to check your own situation).

    So that makes it difficult to know what to do when you are using something else. I assume you are using MinGW. It is not supported for Gurobi, but I have tested it myself on some of the examples. So, I believe it should work for you.

    If you want good build examples for MinGW, you can extract the Linux installer for Gurobi and look at the Makefile in gurobi<version>/linux64/examples. This will show you that the g++ command requires these commands:

        -lgurobi_c++    -lgurobi<version>

    Note that MinGW uses the Linux library naming conventions as well as the more generic approach of specifying the actual file name.

    So I believe you could use this command line for Gurobi 8.1.1 (Note: I have not tested this on my own machine):

     g++ mip1_c++.cpp -o mip1.exe -I c:/gurobi811/win64/include -Lc:/gurobi811/win64/lib -lgurobi_c++mt2017.lib -lgurobi81.lib

    Notice that I specified the library directory with the -L switch. There is no LD_LIBRARY_PATH on Windows.

    Also note: the GRB_LICENSE_FILE setting has no effect until you run the compiled program. It is not a factor when compiling or linking.

    Comment actions Permalink
  • Sebastían Díaz

    Hi i follow your advice and now i am using microsoft visual studio. i follow this guide to configurate gurobi but now i get this error: 


    it says that "cant open the file '******'

    Comment actions Permalink
  • Tirat Demir

    Do you  solved this problem...i have the same rn.

    Comment actions Permalink
  • Dan Jeffrey

    Hello. The instructions still work. My guess is that they are difficult to follow when the default language is no English.

    This error message means that Visual Studio is trying to link to a file named lib.obj. That is not what you want.



    • Find Linker > General > Additional Library Directories. Additional Library Directories is the ninth (9th) item in the list.
    •  ... add: $(GUROBI_HOME)\lib
    • Find Linker > Input > Additional Dependencies. Additional Dependencies is the first (1st) item in the list. Add this to the list of files in that box:



    Comment actions Permalink
  • Matthias Miltenberger

    A completely different solution to this problem might be to try CMake. This is entirely command-line based and may be easier to follow:

    CMake: C/C++ compilation of Gurobi projects

    Compiling C/C++ Projects on Windows


    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk