-
Notifications
You must be signed in to change notification settings - Fork 0
Building Stockfish on macOS
These instructions are by @snicolet.
On macOS 10.14 or higher, it is possible to use the Clang compiler provided by Apple to compile Stockfish out of the box, and this is the method used by default in our Makefile (the Makefile sets the macosx-version-min=10.14 flag to select the right libc++ library for the Clang compiler with recent c++17 support).
But it is quite possible to compile and run Stockfish on older versions of macOS! Below we describe a method to install a recent GNU compiler on these Macs, to get the c++17 support. We have tested the following procedure to install gcc10 on machines running macOS 10.7, macOS 10.9 and macOS 10.13.
-
install Xcode for your machine.
-
install Apple command-line developer tools for Xcode, by typing the following command in a Terminal:
sudo xcode-select --install
- go to the Stockfish "src" directory, then try a default build and run Stockfish:
make clean
make build
make net
./stockfish
-
if step 3 worked, congrats! You have a compiler recent enough on your Mac to compile Stockfish. If not, continue with step 5 to install GNU gcc10 :-)
-
install the MacPorts package manager (https://www.macports.org/install.php), for instance using the fast method in the "macOS Package (.pkg) Installer" section of the page.
-
use the "port" command to install the gcc10 package of MacPorts by typing the following command:
sudo port install gcc10
With this step, MacPorts will install the gcc10 compiler under the name "g++-mp-10" in the /opt/local/bin directory:
which g++-mp-10
/opt/local/bin/g++-mp-10 <--- answer
- You can now go back to the "src" directory of Stockfish, and try to build Stockfish by pointing at the right compiler:
make clean
make build COMP=gcc COMPCXX=/opt/local/bin/g++-mp-10
make net
./stockfish
- Enjoy Stockfish on macOS!
See this pull request for further discussion.