Building and running the example

To build and run the example, we refer the user to the files in <installdir>/examples/build. For Windows platforms, this directory contains C++_examples_2015.sln and C++_examples_2017.sln (Visual Studio 2015 and 2017 solution files for the C++ examples). Double-clicking on the solution file will bring up Visual Studio. Clicking on the mip1_c++ project, and then selecting Run from the Build menu will compile and run the example.

If you want to create your own project or makefile to build a C++ program that calls Gurobi, the details will depend on your platform and development environment, but we'd like to point out a few common pitfalls:

  • Be sure to choose the Gurobi C++ library that is compatible with your Visual Studio version and your choice of runtime library (Gurobi supports runtime library options /MD, /MDd, /MT, and /MTd). To give an example, use file gurobi_c++md2015.lib when you choose runtime library option /MD in Visual Studio 2015. Similarly, use file gurobi_c++mtd2017.lib when you choose runtime library option /MTd in Visual Studio 2017.
  • A C++ program that uses Gurobi must link in both the Gurobi C++ library gurobi_c++mt2015.lib and the Gurobi C library gurobi81.lib.

The C++ example directory <installdir>/examples/c++ contains a number of examples. We encourage you to browse and modify them in order to become more familiar with the Gurobi C++ interface. We also encourage you to read the Gurobi Example Tour for more information.

Try Gurobi for Free

Choose the evaluation license that fits you best, and start working with our Expert Team for technical guidance and support.

Evaluation License
Get a free, full-featured license of the Gurobi Optimizer to experience the performance, support, benchmarking and tuning services we provide as part of our product offering.
Academic License
Gurobi supports the teaching and use of optimization within academic institutions. We offer free, full-featured copies of Gurobi for use in class, and for research.
Cloud Trial

Request free trial hours, so you can see how quickly and easily a model can be solved on the cloud.