How to: setup Gurobi in Apple Xcode (C++)

In this tutorial, I show how to setup Gurobi with Xcode. Note you should have installed Xcode from the App Store and have downloaded and installed Gurobi for MacOS.

In my case, I’m running MacOS 10.13.3, Xcode 9.3 and Gurobi 7.5.2.

To start with, start a new Xcode project and select “MacOS” and “Command Line Tool”

Give it a name and save it.

Under “Build Phases” and “Link Binary with Libraries” click the + button, followed by “Add other…” and add the files and libgurobi_c++.a. In my system, they are located on /Library/gurobi752/mac64/lib. See the following two screenshots.

Now click on “Build Settings” and navigate to “Seach Paths” and add the Gurobi include directory (/Library/gurobi752/mac64/include).

A bit further down, find “Apple LLVM 9.0 – Language – C++” and change the “C++ Standard Library” to “libc++ (LLVM C++ standard library with C++11 support)”. See image below.

That should do the job. I copied one of the examples shipped with Gurobi to my main, hit the Run button, and the result is:

Happy model solving!

This was useful? Buy me a cup of coffee to help me keep this website running!

Published by

Leandro Coelho

Was this useful? Pay me a coffee to help me keep this site running.