Try our new documentation site (beta).
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_2008.sln
,
C++_examples_2010.sln
, and C++_examples_2012.sln
(Visual Studio 2008, 2010, and 2012 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. For Linux or Mac OS platforms, the
<installdir>/examples/build
directory contains an example
Makefile. Typing make mip1_c++
will build and run this
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:
- On Windows, 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 filegurobi_c++md2010.lib
when you choose runtime library option /MD in Visual Studio 2010. Similarly, use filegurobi_c++mtd2012.lib
when you choose runtime library option /MTd in Visual Studio 2012. - A C++ program that uses Gurobi must link in both the Gurobi C++
library (e.g.,
gurobi_c++mt2010.lib
on Windows,libgurobi_c++.a
on Linux and Mac) and the Gurobi C library (gurobi56.lib
on Windows,libgurobi56.so
on Linux and Mac).
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.