Skip to main content

Can't find any gurobi files for C++ in mac

Answered

Comments

9 comments

  • Matthias Miltenberger
    Gurobi Staff Gurobi Staff

    Hi Ishaan,

    Did you properly install Gurobi on your machine already? The C++ files you need to compile and link a Gurobi  project are located in the \(\texttt{src}\) and \(\texttt{lib}\) directories.

    Please also refer to these pages in the documentation and our Knowledge Base for further information:

    I hope that helps.

    Cheers,
    Matthias

    0
  • Ishaan Jolly
    Gurobi-versary
    Conversationalist
    First Question

    Yeah, I did, I used the instructions from installation. But I really cannot find the src and lib directories. Could you guide me to locate those files? 

     

     

    0
  • Ishaan Jolly
    Gurobi-versary
    Conversationalist
    First Question

    Also, I'm clueless about C Make and how to use it? Could you please direct me to understand how to use the two links you have provided? 

    0
  • Matthias Miltenberger
    Gurobi Staff Gurobi Staff

    Hmm, to be honest, this sounds like you would be better off using our Python API. This is way more user-friendly and does not require any code compilation. 

    The src and lib directories are located in your Gurobi installation directory. On macOS, this is typically \(\texttt{/Library/gurobi-9.1.2/macos/}\).

    Can you run

    gurobi_cl

    in your shell/terminal?

    Cheers,
    Matthias

    0
  • Ishaan Jolly
    Gurobi-versary
    Conversationalist
    First Question

    I get this when I run "gurobi_cl" :

    Academic license - for non-commercial use only - expires 2021-11-17

    Using license file /Users/ishaanjolly/gurobi.lic

    Set parameter LogFile to value gurobi.log

     

    Usage: gurobi_cl [--command]* [param=value]* filename

    Type 'gurobi_cl --help' for more information.

    0
  • Ishaan Jolly
    Gurobi-versary
    Conversationalist
    First Question

    Still can't find gurobi files, honestly. I have tried that on path. But, it doesn't work. 

    0
  • Matthias Miltenberger
    Gurobi Staff Gurobi Staff

    Hi Ishaan,

    Could you please run this command:

    which gurobi_cl

    This will print the path to the executable. If you installed Gurobi via our package from the website and not via conda, then this directory also contains all necessary files to use Gurobi with all the different APIs, including C++. You can also install Gurobi again to make sure that all files are there.

    CMake is a tool to generate Makefiles or other build systems depending on your machine and your preference. These can then be used to compile and link the code. If you don't already have a working Makefile or some other build environment, I strongly recommend CMake for this job.

    In case all this sounds confusing and unclear to you, then you should have a look at our Python API.

    I hope this helps.

    Cheers,
    Matthias

    0
  • Ishaan Jolly
    Gurobi-versary
    Conversationalist
    First Question

    Hi Mattihias, 

    Hope you are well! 

    I've finally been able to find Gurobi files. They were located at the place that you rightly indicated. My bad for the inconvenience caused!

    I'm afraid I still don't quite get on how to use CMAKE for the header gurobi_c++.h file. Could you guide me on what now to do? 

    Honestly, I want to learn C++ with Gurobi! It sounds fun and more exciting. I have tried python, I'm afraid the processing times are too much for me. 

    0
  • Matthias Miltenberger
    Gurobi Staff Gurobi Staff

    Hi Ishaan,

    It's good to hear that you found the files.

    Learning C/C++ is tough and I cannot recommend jumping in with some project right away. I suggest going through a few tutorials first to understand the foundations. Otherwise, everything you can do is copy&paste and crossing fingers that your code still works. I know this sounds hard, but so is C/C++.

    Having said that, let me give you a few pointers in the right direction concerning CMake. You need to compile your source files and almost always link them to some libraries. This can be very finicky to get right with all the correct compiler options and commands. Additionally, you don't always have to recompile everything and that's where Makefiles come into play. They compare time stamps and can infer which of your source files actually changed and need recompiling. I consider writing Makefiles even more involved/difficult than coding C/C++ and most people just copy&paste existing Makefile systems or work with a project that has a working build system already.

    CMake, while not being too easy as well, makes the build system process a lot more accessible and maintainable with better human-readable commands. In short, it helps set up the Makefile system for you and I strongly recommend using it over plain, hand-written Makefiles. Furthermore, they can also produce other build systems (Visual Studio solution files, ninja, nmake, etc.) for other platforms like Windows or macOS - the "C" stands for cross-platform, by the way.

    You should go through the CMake article I linked above and try to compile one of the Gurobi example files.

    Please understand that we cannot provide a full C/C++ introduction here and there are plenty of excellent free resources on the internet that can explain all this in more detail.

    Cheers,
    Matthias

    0

Please sign in to leave a comment.