Site views: 1907795



How to compile Stockfish and Stockfish-like programs for Android.

Last edit: 16 June 2021.



I write this article so that no one will take anymore his knowledges only for himself about this argument whitout sharing (then helping) just to boast his ego.



When you look at Android you must think to Linux. Android was originally made as a Linux ‘hack’ to be put on mobile devices (smartphones and tablets); subsequently its use spreaded on other devices, for example Google Home.
My prevision is that soon we will start to see personal computers running Android instead of Windows, Linux or macOS and always more mobile devices instead of personal computers.
I’m saying this because I constantly tracked down the activities on my website: while at the begins it was a ‘computer only’ with a 0.8-1% of mobiles traffic, now the smartphone and tablet users reached something like the 48%(!) of the total usage of it.



This is the way I made (PC ONLY!), I’ve tried with MSYS2 in Windows but it didn’t work. I’m not saying that is the only way to do it, but I’m saying that it works!

1) Install Linux Mint on your computer or on a virtual machine you have created: you can use the free VMware Workstation Player for Windows to do that without even paying anything. The system must be installed on the (virtual or physical) hard drive, instead of ran on the fly like many Linux distribution do nowadays otherwise it won't work.
By installing this distribution you will have both the make and the gcc (mandatories) packages already installed on your Linux, so you won’t have to make any more effort in this sense.

If you still don't have make and/or gcc type in the shell sudo apt-get gcc, install the package, sudo apt-get make and install the package.

2) Download the NDK software from here (use "Latest Beta Version (r23 Beta 5)").

3) Unpack the folder inside the NDK zip package in your Home folder. When you install Linux you have by default a ‘Home’ folder. Rename the extracted folder ndk.

4) Let’s say the user you created in the installation is max, you will have to open the file .bashrc inside your home folder (if you don’t see it click on View on Nemo, the default file browser, then click on Show Hidden Files).


Home folder with compiler


Once opened type

export PATH=$PATH:/home/max/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin

just below

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

and before

# If not running interactively, don't do anything




Save your .bashrc file and close the text editor. Now you have all the compilers installed.




5) Download the Stockfish source package from (click on Code -> Download ZIP)


6) Extract the Stockfish package directly in Home


7) Start the command line and go in the Stockfish-master/src directory (usually type cd Stockfish-master/src then press Enter,

or cd Stockfish-master then cd src)


8) To compile for android you can just use these three commands:

- make build ARCH=armv8 COMP=ndk

if you want to compile for 64bit Androids (the nowadays widest used);

- make build ARCH=armv7-neon COMP=ndk

if you want to compile for 32bit Androids supporting the neon instructions;

- make build ARCH=armv7 COMP=ndk

if you want to compile for standard 32bit Androids (oldest devices).


9) Now you’ll have to strip the stockfish binary, if your compilation succeeded. To strip means to reduce the size of the binary so that it’s faster.

Let’s still take that your user is max:


/home/max/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip stockfish

to strip the produced binary, be it 64-bit (armv8), 32-bit neon (armv7-neon) or 32-bit (armv7).


10) Move the produced ‘stockfish’ (or ‘cfish’ or ‘corchess’ for example) binary in some other folder or directly in your phone (inside for example Droidfish/uci).


11) Type make clean on your command prompt in order to clean the Stockfish-master/src folder.


If you compile programs like Cfish supporting the non embedding make sure to set embed=yes in the Makefile. This will make it working on Android everywhere.


If you want to give a different name than just "stockfish" or "cfish" or "stockfish_polyglot" please don't rename the compiled binary but change the name in the Makefile before the compilation, above in the text file, and then make a compilation (after having saved the modified Makefile with the new name): you should see an EXE = stockfish, or EXE = cfish, change the name there otherwise the program won't be accepted by Acid Ape.


You will get a lot of errors and make a lot of misunderstandings the first times you try these procedures, but don’t worry: with training things will become a lot easier and you'll succeed at the end. If you need help I'm here.


If you have to compile other Stockfish-like programs like Cfish, Stockfish Polyglot or CorChess please bear in mind that they produce binaries will different names:

- cfish for Cfish
- stocfish_polyglot for Stockfish Polyglot
- corchess for CorChess

so you will have to change the name at step 9) ( for example home/max/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip stockfish_polyglot).



Stockfish source:
Stockfish Polyglot source:
Cfish source:
CorChess embedded source:


Massimiliano Goi.


This article has been written under the Creative Commons License: you can freely copy it, modify it and take portions of it. This article is a continuous stub and can be subjected to modifications.



Rate this article: