Introduction
This guide gets you started with OR-Tools in .Net with a simple working example.
Although these instructions might also work on other Linux variants, we have only tested them on machines meeting the following requirements:
- Alpine Edge 64-bit (x86_64)
- Centos Stream 8 64-bit (x86_64)
- Centos 7 64-bit (x86_64)
- Debian 11 (bullseye) 64-bit (x86_64)
- Debian 10 (buster) 64-bit (x86_64)
- Fedora 36 64-bit (x86_64)
- Fedora 35 64-bit (x86_64)
- Fedora 34 64-bit (x86_64)
- Fedora 33 64-bit (x86_64)
- OpenSuse Leap 64-bit (x86_64)
- Ubuntu 22.10 64-bit (x86_64)
- Ubuntu 22.04 LTS 64-bit (x86_64)
- Ubuntu 20.04 LTS 64-bit (x86_64)
- Ubuntu 18.04 LTS 64-bit (x86_64)
Prerequisites
The following sections describe the prerequisites for installing OR-Tools.
.Net Core SDK >= 3.1
Next, install the .Net Core SDK version 3.1 or higher. To do so, open a terminal window and enter:
Alpine
apk add dotnet6-sdk
ref: https://learn.microsoft.com/en-us/dotnet/core/install/linux-alpine
Centos
sudo dnf install -y dotnet-sdk-6.0
ref: https://learn.microsoft.com/en-us/dotnet/core/install/linux-rhel#supported-distributions
Centos
ref: https://learn.microsoft.com/en-us/dotnet/core/install/linux-centos#centos-7sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
sudo yum install -y dotnet-sdk-6.0
Debian
Before you install .NET, run the following commands to add the Microsoft package signing key to your list of trusted keys and add the package repository.
wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
ref: https://learn.microsoft.com/en-us/dotnet/core/install/linux-debiansudo apt update
sudo apt install -y dotnet-sdk-6.0
Debian
Before you install .NET, run the following commands to add the Microsoft package signing key to your list of trusted keys and add the package repository.
wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
ref: https://learn.microsoft.com/en-us/dotnet/core/install/linux-debiansudo apt update
sudo apt install -y dotnet-sdk-6.0
Fedora
sudo dnf install -y dotnet-sdk-6.0
ref: https://learn.microsoft.com/en-us/dotnet/core/install/linux-fedora
Fedora
sudo dnf install -y dotnet-sdk-6.0
ref: https://learn.microsoft.com/en-us/dotnet/core/install/linux-fedora
Fedora
sudo dnf install -y dotnet-sdk-6.0
ref: https://learn.microsoft.com/en-us/dotnet/core/install/linux-fedora
Fedora
sudo dnf install -y dotnet-sdk-6.0
ref: https://learn.microsoft.com/en-us/dotnet/core/install/linux-fedora
OpenSUSE
Before you install .NET, run the following commands to add the Microsoft package signing key to your list of trusted keys and add the package repository.
sudo zypper install libicu
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
wget https://packages.microsoft.com/config/opensuse/15/prod.repo
sudo mv prod.repo /etc/zypp/repos.d/microsoft-prod.repo
sudo chown root:root /etc/zypp/repos.d/microsoft-prod.repo
Then you can install the .Net SDK using the following command:
sudo zypper install -y dotnet-sdk-6.0
ref: https://learn.microsoft.com/en-us/dotnet/core/install/linux-opensuse
Ubuntu
sudo apt install -y dotnet-sdk-6.0
ref: https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu
Ubuntu
sudo apt install -y dotnet-sdk-6.0
ref: https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu
Ubuntu
sudo apt install -y dotnet-sdk-6.0
ref: https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu
Ubuntu
sudo apt install -y dotnet-sdk-6.0
ref: https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu
Get the .Net example code
The example code is located in the dotnet_or-tools repo.
Download the repo as a zip file and unzip it, or clone the repo:
git clone -b v9.6 --depth 1 https://github.com/or-tools/dotnet_or-tools
Change to the examples directory:
cd dotnet_or-tools
Build the example
From the dotnet_or-tools
directory:
Build the project using:
dotnet build -C Release
Run the example
From the dotnet_or-tools
directory:
Run the binary using:
dotnet run -C Release
Congratulations! You've just run an application with OR-Tools, you are ready to get started with OR-Tools.