Introduction
This guide explains how to install OR-Tools from source, with support for Java, on MacOS. Unless you plan to modify the source code or use a third-party solver with OR-Tools, we recommend the binary installation.
Although these instructions might also work on other MacOS variants, we have only tested them on machines meeting the following requirements:
- MacOS 10.14.2 (Mojave) 64-bit (x86_64)
Prerequisites
The following sections describe the prerequisites for installing OR-Tools from source.
Xcode Command Line Tools
You must install the Xcode Command Line Tools. To do so, open the Terminal, found in
/Applications/Utilities/
, and enter:
xcode-select --install
Click “Install” to download and install Xcode Command Line Tools. You don’t need to "Get Xcode" from the App Store. If you have a slow Internet connection, it may take many minutes.
Verify that you’ve successfully installed Xcode Command Line Tools:
xcode-select -p
You should see:
/Applications/Xcode.app/Contents/Developer
Homebrew
To install the remaining prerequisites, we recommend first installing the "missing package manager for macOS" otherwise known as Homebrew. To do so, open a terminal window and enter:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
To verify that you’ve successfully installed brew:
brew --version
You should see:
Homebrew 1.6.9-8-g25542d7 Homebrew/homebrew-core (git revision 0e0c84; last commit 2018-06-20)
C++ tools
To install C++ tools, open a terminal window and enter:
brew install cmake wget
Java tools
To install Java tools, open a terminal window and enter:
brew cask install java
brew install swig maven
Download the source code
There are two distinct branches of the OR-Tools source code on GitHub: stable and master. The stable branch has been thoroughly tested and should work flawlessly on all supported platforms. The master branch is where the latest updates and improvements have been applied; it's more current, but less stable.
Download the stable source code
To get the stable source code for OR-Tools,
clone the stable branch from GitHub
or download the latest release in a compressed file. You can do so by
clicking the Clone or download button
in GitHub.
Download the master source code
To retrieve the source code from the master branch, enter
git clone -b master https://github.com/google/or-tools
Download previous releases
You can get the source code for previous releases in either of the following ways:
- Download a previous release from the GitHub release page.
- Assuming you have already created a local repository (by
git clone
), you can check out a specific release using a Git tag. For example, to work with the v7.4 release instead of the master branch, enter the following commands in your local repo:git fetch --all --tags --prune>
git checkout tags/v7.2 -b v7.2>
Build the source code
To build the source code:
- Open a terminal and navigate to the directory where you extracted the files.
Then enter the following command:
make third_party
- To use a third party solver,
open
Makefile.local
in the mainor-tools
directory, and add the path to the directory where you installed the solver. For example, for SCIP you would add this:UNIX_SCIP_DIR=scip/install/dir
- Compile OR-Tools by entering
make java
- You can check that everything is running correctly by entering
make test_java
This runs a selection of examples for OR-Tools. If all the examples run successfully, you are ready to get started with OR-Tools.
Using a third-party solver
You can use OR-Tools with any of the following third-party solvers:
If you have already installed OR-Tools and want to configure it to use one of these solvers, do the following steps:
- Open a terminal and navigate to the
or-tools
directory. Then enter the following command:make third_party
- Open
Makefile.local
and add the path to the directory where you installed the solver. For example, for SCIP you would add this:UNIX_SCIP_DIR=scip/install/dir
- Compile OR-Tools by entering
make clean
make all
Install the SCIP Optimization Suite
To install the SCIP Optimization Suite on a Mac, do the following steps:
- Download the SCIP archive and unpack it.
- Navigate to the top level of the unpacked archive and enter the following commands:
make GMP=false READLINE=false TPI=tny ZIMPL=false PARASCIP=true scipoptlib install INSTALLDIR=/scip/install/dir
make
make install
After the installation is complete, follow the instructions in Using a third-party solver.
Cleaning the build files
If you need to re-install OR-Tools, the command:
make clean_third_party
will remove all compiled dependencies and Makefile.local
. This can be useful
for resetting to a clean state.
Then re-enter the commands
make third_party
make java