This article assumes that you have installed a Gurobi 9.0 release on your Windows computer using the MSI installer. It's easiest to modify one of the existing projects in the examples\build subdirectory of your Gurobi installation.
However, if you prefer to create a new project from scratch, these are the key steps:
Enable C++ development in Visual Studio
In order to develop C++ applications, you need to install the required components through the Visual Studio Installer. Documentation is available at https://docs.microsoft.com/en-us/visualstudio/install/install-visual-studio?view=vs-2019.
Within the Visual Studio Installer select Workloads and select "Desktop development with C++". This will automatically mark the appropriate components (compiler, SDK and other productivity tools) for installation.
Create the project:
- Select "Create a new project" in the startup window or under the File menu, select New > Project...
- Type C++ in the "All languages" dropdown menu and select Console App. Click "Next" For this article, we use gurobitest as Project name in the next window.
- Press the Create button to close the Wizard.
Add an existing source file:
- In the Solution Explorer, under the Project name (gurobitest) > Source Files, right click on gurobitest.cpp. Select Remove, then press Delete.
- Right-click on the project name (gurobitest) in the Solution Explorer panel, then select Add > Existing Item..., then choose your C++ source file.
Configure the project:
- Right-click on the project name in the Solution Explorer panel, then select Properties.
- Set Platform to x64
- Set Configuration to All Configurations
- Under Debugging set Environment to PATH=$(PATH);$(GUROBI_HOME)\lib
- Under C/C++ > General > Additional Include Directories, add: $(GUROBI_HOME)\include
- Under C/C++ > Precompiled Headers > Precompiled Header, select Not Using Precompiled Headers
- Under Linker > General > Additional Library Directories, add: $(GUROBI_HOME)\lib
- Set Configuration to Debug
- Under Linker > Input > Additional Dependencies, add gurobi90.lib; gurobi_c++mdd2019.lib
- Set Configuration to Release
- Under Linker > Input > Additional Dependencies, add gurobi90.lib; gurobi_c++md2019.lib
When building your project, make sure the current target in the Visual Studio toolbar is x64 (it usually defaults to x86).