building for Android

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

jdart
Posts: 4366
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: building for Android

Post by jdart »

/data/local seems to not be accessible on my phone.

--Jon
User avatar
pedrox
Posts: 1056
Joined: Fri Mar 10, 2006 6:07 am
Location: Basque Country (Spain)

Re: building for Android

Post by pedrox »

jdart wrote:/data/local seems to not be accessible on my phone.

--Jon
I am sorry. This worked on my phone that does not have root, maybe the rom is pre-rooted.
User avatar
abik
Posts: 819
Joined: Fri Dec 01, 2006 10:46 pm
Location: Mountain View, CA, USA
Full name: Aart Bik

Re: building for Android

Post by abik »

I pulled your tree from github and had not too much trouble making a position-independent executable with the NDK compiler toolchain. I am not sure what scripts you are using, but perhaps using the compiler directly will help, since it works for me.

Code: Select all

# ./arasanx-ab                                          
Arasan 20.0-ab Copyright 1994-2017 by Jon Dart. All Rights Reserved.
uci
id name Arasan 20.0-ab
id author Jon Dart
option name Hash type spin default 32 min 4 max 2000
option name Ponder type check default true
option name MultiPV type spin default 1 min 1 max 10
option name OwnBook type check default true
option name Book selectivity type spin default 50 min 0 max 100
option name Threads type spin default 1 min 1 max 64
option name UCI_LimitStrength type check default false
option name UCI_Elo type spin default 2600 min 1000 max 2600
uciok
go
info multipv 1 depth 1 score cp 58 time 0 nodes 0 hashfull 0 pv e2e3
info multipv 1 depth 1 score cp 58 time 1 nodes 21 hashfull 0 pv e2e3
info multipv 1 depth 2 score cp 0 time 6 nodes 467 hashfull 0 pv e2e3 e7e6
info multipv 1 depth 3 score cp 54 time 11 nodes 1045 hashfull 0 pv e2e3 d7d5 b1c3
info multipv 1 depth 3 score cp 54 time 11 nodes 1045 hashfull 0 pv e2e3 d7d5 b1c3
bestmove e2e3 ponder d7d5
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: building for Android

Post by Ras »

jdart wrote:I downloaded the NDK and followed the instructions to set up a standalone toolchain. I used this command:

$NDK/build/tools/make_standalone_toolchain.py --install-dir=/home/jdart/chess/chess/android-toolchain-clang --arch arm --api 9 --stl=libc++
I know this thread is a bit dated, but there's a gotcha: the PIE position independent code is required from Android 5.0, but it is only supported from API level 16 onwards. Generating the toolchain with API level 9 is likely not to work.
jdart
Posts: 4366
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: building for Android

Post by jdart »

Thanks for the hint. I am going to revisit this eventually. However, last I tried it I was stuck at the last issue I mentioned: getting the executable on to the one Android device I have (Samsung Galaxy S7) in a form that is runnable there.

--Jon
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: building for Android

Post by Ras »

jdart wrote:Thanks for the hint. I am going to revisit this eventually.
I'm not familiar with C++ and its implications for Android; however, my C-engine works under PC-Linux, and from there, it was easy to get an Android build done. In fact so easy that I managed to do it although I don't even own an Android device.

The workflow is, for Windows:
- copying the Android NDK to the host.
- using the build/tools/make_standalone_toolchain.py script with the correct parameters.
- having a build script that uses the resulting tool chain.

I'm using NDK 15c because 16b seems to have some issues with x86 Android, not quite sure here what it is. But for Galaxy S7, that doesn't matter anyway.

It seems that using e.g. Chess for Android, all you have to to is to put the engine on the SD card and then use the "install engine from SD card" feature. Aart has figured out all the complicated stuff, so as engine programmer, it's just providing a runnable executable.