ChessUSA.com TalkChess.com
Hosted by Your Move Chess & Games
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Android build fails?
Post new topic    TalkChess.com Forum Index -> Computer Chess Club: Programming and Technical Discussions Flat
View previous topic :: View next topic  
Author Message
Rasmus Althoff



Joined: 30 Aug 2016
Posts: 631

PostPost subject: Re: Android build fails?    Posted: Thu Jul 13, 2017 10:40 pm Reply to topic Reply with quote

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:
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:
-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:
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:
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.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Subject Author Date/Time
Android build fails? Rasmus Althoff Fri Jul 07, 2017 11:02 pm
      Re: Android build fails? Jon Dart Sat Jul 08, 2017 2:57 am
            Re: Android build fails? Rasmus Althoff Sat Jul 08, 2017 9:04 am
      Re: Android build fails? Rasmus Althoff Thu Jul 13, 2017 10:40 pm
            Re: Android build fails? Salvatore Giannotti Tue Sep 19, 2017 1:33 pm
                  Re: Android build fails? Gurcan Uckardes Sat Sep 23, 2017 3:23 pm
                        Re: Android build fails? Rasmus Althoff Sat Sep 30, 2017 5:50 pm
                        Re: Android build fails? Salvatore Giannotti Mon Dec 04, 2017 10:42 pm
                              Re: Android build fails? Aart Bik Tue Dec 05, 2017 6:20 pm
                                    Re: Android build fails? Salvatore Giannotti Tue Dec 05, 2017 9:04 pm
            Re: Android build fails? Rasmus Althoff Wed Nov 29, 2017 12:05 am
Post new topic    TalkChess.com Forum Index -> Computer Chess Club: Programming and Technical Discussions

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Powered by phpBB © 2001, 2005 phpBB Group
Enhanced with Moby Threads