Android build fails?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

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

Re: Android build fails?

Post by Ras »

Just wanted to share the results, maybe it's of interest for people thinking about an Android port. It's quite easy for a C engine.

- Get the Android NDK (not the SDK).
- Use the python script android-ndk-r15b/build/tools/make_standalone_toolchain.py with the following options:

Code: Select all

make_standalone_toolchain.py --arch arm --api 16 --unified-headers --install-dir c:\android-standalone-chain
API level 16 is important because that's the minimum where position independent executables (PIE) are supported - and from Android 5.0, that is even mandatory. By default, the script would assume API level 14, so the code would be unlikely to work with Android 5.0.
- I'm using the following build options for Clang:

Code: Select all

-march=armv7-a -m32 -mfloat-abi=softfp -mfpu=vfpv3-d16 -pie -fPIE -Wl,--fix-cortex-a8 -Wall -Wuninitialized -Wstrict-aliasing -Wno-unused-command-line-argument -O2 -std=c99 -fno-strict-aliasing -fno-strict-overflow -ffunction-sections -fdata-sections -Wl,--gc-sections -static
- the binary size can be reduced further using arm-linux-androideabi-strip in the bin/ directory:

Code: Select all

arm-linux-androideabi-strip --strip-unneeded  enginebinary
stdin/stdout work as usual. The only code change I had to make was for the time routine. ftime() from sys/timeb.h isn't available, but that function is obsolete anyway. Instead (works also with MingW), use sys/time.h like so:

Code: Select all

int64_t millisecs;
struct timespec timebuffer;
clock_gettime(CLOCK_MONOTONIC, &timebuffer);
millisecs = ((int64_t) timebuffer.tv_sec)*1000LL + (int64_t) (timebuffer.tv_nsec / 1000000L);
That will leave you with an Android engine. Using the GUI "Chess for Android" which can install an engine from SD card will do the rest.
sasachess
Posts: 24
Joined: Wed Nov 05, 2014 11:28 am
Location: Italy

Re: Android build fails?

Post by sasachess »

I was looking for a way to compile from windows to android and finally I succeeded. It works perfectly. Thank you for sharing!
Gurcan Uckardes
Posts: 196
Joined: Wed Oct 29, 2014 12:42 am

Re: Android build fails?

Post by Gurcan Uckardes »

So, i wanna ask whether we may receive some outcome to test and rate under Android? Thanks.
My blog for Android users: http://chesstroid.blogspot.com
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Android build fails?

Post by Ras »

For the CT800 engine, that will be part of the release V1.12, planned for mid-October.
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Android build fails?

Post by Ras »

Update: from NDK r16 on, the "unified headers" are the only option, which is why the python generation script doesn't accept the "--unified-headers" option anymore. The script must be called like that:

Code: Select all

make_standalone_toolchain.py --arch arm --api 16 --install-dir c:\android-standalone-chain
sasachess
Posts: 24
Joined: Wed Nov 05, 2014 11:28 am
Location: Italy

Re: Android build fails?

Post by sasachess »

Gurcan Uckardes wrote:So, i wanna ask whether we may receive some outcome to test and rate under Android? Thanks.
I just released version 1.4, including the executable for Android. Please can you test it and tell me if it works? :)

Thank you!

http://sasachess.altervista.org/gogobello
User avatar
abik
Posts: 819
Joined: Fri Dec 01, 2006 10:46 pm
Location: Mountain View, CA, USA
Full name: Aart Bik

Re: Android build fails?

Post by abik »

sasachess wrote:I just released version 1.4, including the executable for Android. Please can you test it and tell me if it works? :)
Seems to work just fine!

Code: Select all

# ./gogobello-android                                                                                        
-------------------------------------------------------------------------------
gogobello chess engine by Salvatore Giannotti
Version 1.4

-------------------------------------------------------------------------------
enter 'console' for console mode... uci

id name gogobello 1.4
id author Salvatore Giannotti
option name Ponder type check default true
option name Hash type spin default 128 min 1 max 8192
option name Clear Hash type button
option name HashEvalSize type spin default 8 min 1 max 1024
option name HashQSize type spin default 8 min 1 max 1024
option name HashPawnSize type spin default 4 min 1 max 24
option name Thread type spin default 1 min 1 max 24
option name OwnBook type check default true
option name RandBook type check default false
option name BookFile type string default Morphius_12.9c.bin
option name Syzygy type check default true
option name dtzPath type string default <empty>
option name wdlPath type string default <empty>
option name SyzygyMen type spin default 5 min 2 max 6
option name SuddenDeath type spin default 20 min 10 max 50
option name MoreTime type spin default 5 min 5 max 15
option name LessTime type spin default 10 min 5 max 15
option name FastGame type spin default 5 min 5 max 15
option name FastOpening type spin default 10 min 5 max 15
Allocated   128 MB for the Hash Table
Allocated     4 MB for the HashPawn Table for Thread 1
Allocated     8 MB for the HashEval Table for Thread 1
Allocated     8 MB for the HashQ Table for Thread 1
uciok
sasachess
Posts: 24
Joined: Wed Nov 05, 2014 11:28 am
Location: Italy

Re: Android build fails?

Post by sasachess »

abik wrote: Seems to work just fine!
Great! I'd be curious to know the elo under Android..