CMake is a platform-independent build system to compile C/C++ code. To link Gurobi into your project you can extend the template attached to this article, which contains:
- FindGUROBI.cmake to determine the necessary include and linker commands
- CMakeLists.txt to specify how your code needs to be built
Build a C/C++ project on Windows
cmake -H. -Bbuild
cmake --build build --config Release [Debug]
Build a C/C++ project on Linux/macOS
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release [Debug]
cmake --build build
To build a pure C project, you can specify -DCXX=off in the first step.
These commands will create a new subdirectory named build where the compiled files can be found. On Windows, the resulting executable is located in build\Release\.
Note: This template uses mip1_c++.cpp from the Gurobi C++ examples directory.
- How do I resolve "undefined reference" errors while linking Gurobi in C++?
- How do I build C/C++ projects on Windows?