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

#320 in Math

Download history 7/week @ 2022-11-25 16/week @ 2022-12-02 45/week @ 2022-12-09 12/week @ 2022-12-16 18/week @ 2022-12-23 7/week @ 2022-12-30 18/week @ 2023-01-06 4/week @ 2023-01-13 19/week @ 2023-01-20 17/week @ 2023-01-27 37/week @ 2023-02-03 57/week @ 2023-02-10 77/week @ 2023-02-17 21/week @ 2023-02-24 18/week @ 2023-03-03 11/week @ 2023-03-10

127 downloads per month
Used in 2 crates

MIT license

4.5K SLoC

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.


~30K SLoC