8 stable releases

1.3.0 Nov 16, 2021
1.2.0 Oct 19, 2021
1.0.4 May 18, 2021
1.0.3 Apr 19, 2021
1.0.1 Feb 18, 2021

#501 in Math

Download history 36/week @ 2023-10-29 23/week @ 2023-11-05 31/week @ 2023-11-12 27/week @ 2023-11-19 54/week @ 2023-11-26 16/week @ 2023-12-03 50/week @ 2023-12-10 77/week @ 2023-12-17 40/week @ 2023-12-24 12/week @ 2023-12-31 22/week @ 2024-01-07 28/week @ 2024-01-14 33/week @ 2024-01-21 26/week @ 2024-01-28 22/week @ 2024-02-04 54/week @ 2024-02-11

140 downloads per month
Used in 2 crates

MIT license


grb GitHub tag (latest SemVer)

This crate provides Rust bindings for Gurobi Optimizer. It currently requires Gurobi 9.0 or higher.

This library started as fork of the gurobi which appears to be no longer maintained. It has since undergone a number of fundamental API changes.

Installing and Linking

  • Before using this crate, you should install Gurobi and obtain a license.


Make sure that the environment variable GUROBI_HOME is set to the installation path of Gurobi (like C:\gurobi911\win64 or /opt/gurobi911/linux64). If you are using the Conda package from the Gurobi channel, the build script will fall back to GUROBI_HOME=${CONDA_PREFIX}, so you should not set GUROBI_HOME.


When running the compiled binaries or running tests, you may get

error while loading shared libraries: libgurobi91.so: cannot open shared object file: No such file or directory

In this case, you need to set the LD_LIBRARY_PATH environment variable or embed the path to libgurobi.so in the rpath by supplying the appropriate linker flags in RUSTFLAGS.

For the examples below, suppose Gurobi is in the path /opt/gurobi/linux64/libgurobi91.so


cargo build
export LD_LIBRARY_PATH="/opt/gurobi/linux64/:${LD_LIBRARY_PATH}"
target/debug/my_program # or: cargo test

LD_LIBRARY_PATH will need to be set every time the binary is run in a new shell session. If you use conda environments, this is the recommended approach (see here).

Method #2: rpath

export RUSTFLAGS="-C link-args=-Wl,-rpath=/opt/gurobi/linux64/"
cargo build
target/debug/my_program  # or: cargo test

This has the advantage that you don't need to set anything when you want to run the binary in a new shell session. On the other hand, the path to Gurobi is baked into my_program, so it is no longer portable.


Docs can be found on docs.rs


This software is released under the MIT license.


~38K SLoC