Requirements : Android device (64 bit recommended) with atleast 1GB free space , internet connection required and no root required.
# Download Termux from playstore.
# Give permission to storage
https://play.google.com/store/apps/details?id=com.termux
# Install necessary package using pkg or apt
pkg install make
pkg install clang
pkg install git
pkg update
# Download Source code
git clone https://github.com/syzygy1/Cfish
# Compiling the source
cd Cfish/src
make
make build ARCH=armv8 COMP=clang COMPCC=aarch64-linux-android-clang numa=no
# Run Benchmark
./cfish bench
# Move/Copy your engine to Droidfish
cp cfish /storage/emulated/0/DroidFish/uci (coping)
mv cfish /storage/emulated/0/DroidFish/uci ( moving)
# Some Issues related to Termux building.
Since we are not using ndk for compiling the performance is below average and Engine written in C++ like SF will only work in Termux not in any GUIs only Cfish and CiChess will work in both Termux and other GUIs ,But you can still use your compilation for tournament using "cutechess-cli" in Termux only.
Don't worry soon I will be posting another tutorial to fix these issues , If you see my compilation was faster because I used ndk to compile , Yes !! ndk is available for Termux but still I there are some issues to resolve. Thank U for Reading this have a nice day.
Regards
Compiling Engine using Termux on Android
Moderators: Elijah, Igbo, timetraveller
-
- Forum Contributions
- Points: 15 587,00
- Posts: 233
- Joined: 19/01/2020, 17:51
- Status: Offline (Active 2 Weeks, 1 Day, 10 Hours, 53 Minutes ago)
- Topics: 14
- Reputation: 229
- Location: Edge of the World
- Has thanked: 159 times
- Been thanked: 188 times
-
- Forum Contributions
- Points: 15 587,00
- Posts: 233
- Joined: 19/01/2020, 17:51
- Status: Offline (Active 2 Weeks, 1 Day, 10 Hours, 53 Minutes ago)
- Topics: 14
- Reputation: 229
- Location: Edge of the World
- Has thanked: 159 times
- Been thanked: 188 times
Compiling Engine using Termux on Android
As per my promise I am releasing my 2nd tutorial with Termux + NDK it will little bit complicated and lengthy but I will try my best. In this tutorial I will be compiling Stockfish for Android 64 bit
Requirements : Android device (64 bit only) atleast 5 GB free space and 4 GB Ram (Recommended) , internet connection and no root required.
# Packages required wget ,git ,make ,clang , llvm and
build-essential.
$ pkg install <package-name>
# Downloading NDK in Termux. Its recommend to type first wget in Termux than after copy-paste the link.
$ wget https://github.com/Lzhiyong/termux-ndk/releases/download/android-ndk-r21b/android-ndk-r21b.tar.xz
Extracting the NDK it will take a while please be patient.
$ tar xf android-ndk-r21b.tar.xz
#Set the NDK executables in .bashrc file.
$ export PATH=$PATH:/data/data/com.termux/files/home/android-ndk-r21b/toolchains/llvm/prebuilt/linux-aarch64/bin
# Link NDK executables to Termux library.
$ export LD_LIBRARY_PATH=/data/data/com.termux/files/usr/lib
# NDK set up is complete now we are moving Downloading and compiling the source code.
$ git clone https://github.com/official-stockfish/Stockfish
# Moving to source directory and compiling it.
$ cd Stockfish/src
$ make build ARCH=armv8 COMP=ndk
# If it's give you fatal error (like it most of time it's gives me)header missing like <fstream> , <istream>
its because std lib++ is not loaded in main memory, you have to first build using "clang" and built-in cross compiler "aarch64-linux-android-clang++" after that remove that build (because its useless without ndk) and run again the NDK build command. This just my theory I am not 100% sure why it's actually happened but my trick works.
# Compile it and remove it.
$ make build ARCH=armv8 COMP=clang COMPCXX=aarch64-linux-android-clang++
$ rm stockfish
#Now run again ndk command again.
$ make build ARCH=armv8 COMP=ndk
$ ./stockfish bench
# Now we are using NDK builds are little bit bulky ,so the size need to be reduced
$ strip stockfish
# If you want to rename your build like you want to add date and arch ,So rename it before compiling it by editing in Makefile using nano text editor
$ nano Makefile (change the name by replacing stockfish
from EXE=stockfish with you desired your
name and save using CTRL + X)
# Some minor issues related Termux building
We can't create PGO builds and arm7 builds because many libraries are missing or are not supported in Termux.
Performance of build depends upon the Phones's SoC, Phones with newer big Cores like Cortex-A75 will likely to have better performance.
# Some Important announcement
1. please do not post your queries regarding the tutorial here , post it in Android Engine Discussion thread.
2. Soon I will release my video tutorial of Tutorial 1 because many members are facing issue in git clone.
3.If somebody want to use my tutorial including Video tutorial for their Blog or Website can freely use it but have to include my name and Outskirts forum as it from our forum and why me because I just want to be famous.
BEST REGARDS
Requirements : Android device (64 bit only) atleast 5 GB free space and 4 GB Ram (Recommended) , internet connection and no root required.
# Packages required wget ,git ,make ,clang , llvm and
build-essential.
$ pkg install <package-name>
# Downloading NDK in Termux. Its recommend to type first wget in Termux than after copy-paste the link.
$ wget https://github.com/Lzhiyong/termux-ndk/releases/download/android-ndk-r21b/android-ndk-r21b.tar.xz
Extracting the NDK it will take a while please be patient.
$ tar xf android-ndk-r21b.tar.xz
#Set the NDK executables in .bashrc file.
$ export PATH=$PATH:/data/data/com.termux/files/home/android-ndk-r21b/toolchains/llvm/prebuilt/linux-aarch64/bin
# Link NDK executables to Termux library.
$ export LD_LIBRARY_PATH=/data/data/com.termux/files/usr/lib
# NDK set up is complete now we are moving Downloading and compiling the source code.
$ git clone https://github.com/official-stockfish/Stockfish
# Moving to source directory and compiling it.
$ cd Stockfish/src
$ make build ARCH=armv8 COMP=ndk
# If it's give you fatal error (like it most of time it's gives me)header missing like <fstream> , <istream>
its because std lib++ is not loaded in main memory, you have to first build using "clang" and built-in cross compiler "aarch64-linux-android-clang++" after that remove that build (because its useless without ndk) and run again the NDK build command. This just my theory I am not 100% sure why it's actually happened but my trick works.
# Compile it and remove it.
$ make build ARCH=armv8 COMP=clang COMPCXX=aarch64-linux-android-clang++
$ rm stockfish
#Now run again ndk command again.
$ make build ARCH=armv8 COMP=ndk
$ ./stockfish bench
# Now we are using NDK builds are little bit bulky ,so the size need to be reduced
$ strip stockfish
# If you want to rename your build like you want to add date and arch ,So rename it before compiling it by editing in Makefile using nano text editor
$ nano Makefile (change the name by replacing stockfish
from EXE=stockfish with you desired your
name and save using CTRL + X)
# Some minor issues related Termux building
We can't create PGO builds and arm7 builds because many libraries are missing or are not supported in Termux.
Performance of build depends upon the Phones's SoC, Phones with newer big Cores like Cortex-A75 will likely to have better performance.
# Some Important announcement
1. please do not post your queries regarding the tutorial here , post it in Android Engine Discussion thread.
2. Soon I will release my video tutorial of Tutorial 1 because many members are facing issue in git clone.
3.If somebody want to use my tutorial including Video tutorial for their Blog or Website can freely use it but have to include my name and Outskirts forum as it from our forum and why me because I just want to be famous.
BEST REGARDS
-
- Points: 0,00
- Status: Offline (Active 2 Hours, 14 Minutes ago)
- Topics:
Compiling Engine using Termux on Android
For that reason this thread is locked, if you'll need to add later any comments etc, let us know.leonhurricaneX wrote: 1. please do not post your queries regarding the tutorial here , post it in Android Engine Discussion thread.
-
- Forum Contributions
- Points: 15 587,00
- Posts: 233
- Joined: 19/01/2020, 17:51
- Status: Offline (Active 2 Weeks, 1 Day, 10 Hours, 53 Minutes ago)
- Topics: 14
- Reputation: 229
- Location: Edge of the World
- Has thanked: 159 times
- Been thanked: 188 times
Android engines discussion etc.
As promised Video Tutorial 1 (no ndk required and for both 32bit and 64 bit users).
https://www.dropbox.com/s/ctmcgp9l6gj7nkr/Tutorial%201.mp4?dl=0
Added funny intro ,subtitles and background music so no one gets confused or bored.
Skynet please move my post to Tutorial Thread.
https://www.dropbox.com/s/ctmcgp9l6gj7nkr/Tutorial%201.mp4?dl=0
Added funny intro ,subtitles and background music so no one gets confused or bored.
Skynet please move my post to Tutorial Thread.
-
- Forum Contributions
- Points: 15 587,00
- Posts: 233
- Joined: 19/01/2020, 17:51
- Status: Offline (Active 2 Weeks, 1 Day, 10 Hours, 53 Minutes ago)
- Topics: 14
- Reputation: 229
- Location: Edge of the World
- Has thanked: 159 times
- Been thanked: 188 times
Android engines discussion etc.
Yeah ndk is updated now it's support Clang 12.0.2Walkot wrote:The address of the link to termux-ndk has changed, due to the update:https://github.com/Lzhiyong/termux-ndk/releases/download/android-ndk/android-ndk-r22.tar.xz(Compiling Engine using Termux on Android). Please ask the author to correct the link.
$ wget https://github.com/Lzhiyong/termux-ndk/releases/download/android-ndk/android-ndk-r22.tar.xz
$ tar xf android-ndk-r22.tar.xz
$ export PATH=$PATH:/data/data/com.termux/files/home/android-ndk-r22/toolchains/llvm/prebuilt/linux-aarch64/bin
Now the multiple headers missing and lib_shared.so not found bugs are being fixed in this update so we don't need to set custom path for libraries and headers files.
Please Skynet move this post to Compiling Thread.
-
- Forum Contributions
- Points: 15 587,00
- Posts: 233
- Joined: 19/01/2020, 17:51
- Status: Offline (Active 2 Weeks, 1 Day, 10 Hours, 53 Minutes ago)
- Topics: 14
- Reputation: 229
- Location: Edge of the World
- Has thanked: 159 times
- Been thanked: 188 times
Android engines discussion etc.
[woo Even without LTO support GCC builds are still faster than Clang builds in my arm8 device.
Snapdragon 636 bench 16 1 13 default depth NNUE.
Finally we knew to make PGO builds using Termux's GCC.
ARM8 is compiled using NDK's Clang 12.0.2 and aarch64 and PGO using Termux GCC 10.2.0
We can check SF compiler using this compiler command.
$ ./Stockfish-pgo-090221-aarch64 compiler
$ ./Stockfish-090221-arm8 compiler
Snapdragon 636 bench 16 1 13 default depth NNUE.
Code: Select all
SF 090221arm7 (Clang) SF 090221 armv7 (GCC)
--------------------------------------------------------
261652 269066
261769 270124
262752 269926
261752 268278
Code: Select all
SF-090221-arm8 SF-090221-aarch64 SF 090221-PGO-aarch64
--------------------------------------------------------
321951 331854 335883
323112 330491 334483
324008 329413 335697
324008 329881 336157
ARM8 is compiled using NDK's Clang 12.0.2 and aarch64 and PGO using Termux GCC 10.2.0
We can check SF compiler using this compiler command.
$ ./Stockfish-pgo-090221-aarch64 compiler
► Show Spoiler
$ ./Stockfish-090221-arm8 compiler
► Show Spoiler