Steps to compile for Android

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
User avatar
asanjuan
Posts: 211
Joined: Thu Sep 01, 2011 3:38 pm
Location: Seville, Spain

Steps to compile for Android

Post by asanjuan » Wed Mar 19, 2014 10:17 am

Hi all,
My friends are asking me when I'm going to make an android version of my UCI engine Rhetoric. I wonder which are the steps to build such version because I've never compiled anything to that platform.

do I have to change something in the uci protocol?
is so simple as compile for the arm processor?
Is there a tutorial? Any reference guide?

I need a hint.

Thanks in advance.

User avatar
pedrox
Posts: 992
Joined: Fri Mar 10, 2006 5:07 am
Location: Basque Country (Spain)
Contact:

Re: Steps to compile for Android

Post by pedrox » Wed Mar 19, 2014 12:19 pm

Hi Alberto,

I use Sourcery Codebench Lite Edition, it is free. You can install it on Windows or Linux.

http://www.mentor.com/embedded-software ... e-edition/

It uses the GCC compiler, so it is important that your engine can compile without error with this compiler.

So far, the package does not include an IDE, so I have a make file to compile on Windows.

Code: Select all

# Project: danasah

CC       = arm-none-linux-gnueabi-gcc

OBJ      = aleatorio.o atacado.o busqueda.o danasah.o egbb.o entradas.o evalua.o fen.o generamovimientos.o hash.o leer_archivo_ini.o libro.o salidas.o see.o test.o variables.o xboard.o

LIBS     = -static -lm -ldl

BIN      = danasah

CFLAGS   = -mtune=arm7 -DUNDER_ARM -ffunction-sections -fomit-frame-pointer -flto -w -s -Ofast -Wall -Wextra -pedantic -Werror -Wfatal-errors

RM       = del

.PHONY: all all-before all-after clean clean-custom

all: all-before $(BIN) all-after

clean: clean-custom
	${RM} $(OBJ) $(BIN)

$(BIN): $(OBJ)
	$(CC) $(OBJ) -o $(BIN) $(LIBS)

aleatorio.o: aleatorio.c
	$(CC) -c aleatorio.c -o aleatorio.o $(CFLAGS)

atacado.o: atacado.c
	$(CC) -c atacado.c -o atacado.o $(CFLAGS)

busqueda.o: busqueda.c
	$(CC) -c busqueda.c -o busqueda.o $(CFLAGS)

danasah.o: danasah.c
	$(CC) -c danasah.c -o danasah.o $(CFLAGS)

egbb.o: egbb.c
	$(CC) -c egbb.c -o egbb.o $(CFLAGS)

entradas.o: entradas.c
	$(CC) -c entradas.c -o entradas.o $(CFLAGS)

evalua.o: evalua.c
	$(CC) -c evalua.c -o evalua.o $(CFLAGS)

fen.o: fen.c
	$(CC) -c fen.c -o fen.o $(CFLAGS)

generamovimientos.o: generamovimientos.c
	$(CC) -c generamovimientos.c -o generamovimientos.o $(CFLAGS)

hash.o: hash.c
	$(CC) -c hash.c -o hash.o $(CFLAGS)

leer_archivo_ini.o: leer_archivo_ini.c
	$(CC) -c leer_archivo_ini.c -o leer_archivo_ini.o $(CFLAGS)

libro.o: libro.c
	$(CC) -c libro.c -o libro.o $(CFLAGS)

salidas.o: salidas.c
	$(CC) -c salidas.c -o salidas.o $(CFLAGS)

see.o: see.c
	$(CC) -c see.c -o see.o $(CFLAGS)

test.o: test.c
	$(CC) -c test.c -o test.o $(CFLAGS)

variables.o: variables.c
	$(CC) -c variables.c -o variables.o $(CFLAGS)

xboard.o: xboard.c
	$(CC) -c xboard.c -o xboard.o $(CFLAGS)

I use a compiler directive UNDER_ARM to create specific code for Android, but more than anything this is for the opening book and bitbases (to Android find a file we must give a full path).

You do not need to change the code of your engine DroidFish or Chess for Android recognize the uci format as if it were a Windows GUI.

flok

Re: Steps to compile for Android

Post by flok » Wed Mar 19, 2014 3:33 pm

pedrox wrote:Hi,

Code: Select all

# Project: danasah
...
OBJ      = aleatorio.o atacado.o busqueda.o danasah.o egbb.o entradas.o evalua.o fen.o generamovimientos.o hash.o leer_archivo_ini.o libro.o salidas.o see.o test.o variables.o xboard.o
...
all: all-before $(BIN) all-after
...
$(BIN): $(OBJ)
	$(CC) $(OBJ) -o $(BIN) $(LIBS)
Any particular reason that you specify for each c-file how to compile it to an object-file? Make should figure that out by itself?

Code: Select all

aleatorio.o: aleatorio.c
	$(CC) -c aleatorio.c -o aleatorio.o $(CFLAGS)

atacado.o: atacado.c
	$(CC) -c atacado.c -o atacado.o $(CFLAGS)
...

User avatar
pedrox
Posts: 992
Joined: Fri Mar 10, 2006 5:07 am
Location: Basque Country (Spain)
Contact:

Re: Steps to compile for Android

Post by pedrox » Wed Mar 19, 2014 5:48 pm

I used the makefile file that automatically generates dev-cpp on Windows when is used the IDE to compile and then modify shortly this makefile file to compile for Android.

For this reason each file is specified.

Here makefile for Windows:

Code: Select all

# Project: danasah506
# Makefile created by Dev-C++ 5.4.1

CPP      = g++.exe
CC       = gcc.exe
WINDRES  = windres.exe
OBJ      = aleatorio.o atacado.o busqueda.o danasah.o egbb.o entradas.o evalua.o fen.o generamovimientos.o hash.o leer_archivo_ini.o libro.o salidas.o see.o test.o variables.o xboard.o
LINKOBJ  = aleatorio.o atacado.o busqueda.o danasah.o egbb.o entradas.o evalua.o fen.o generamovimientos.o hash.o leer_archivo_ini.o libro.o salidas.o see.o test.o variables.o xboard.o
LIBS     = -L"C:/Users/Pedro/Desktop/Dev-Cpp/MinGW32/lib" -static-libstdc++ -static-libgcc -lgcov  -m32
INCS     = -I"C:/Users/Pedro/Desktop/Dev-Cpp/MinGW32/include"
CXXINCS  = -I"C:/Users/Pedro/Desktop/Dev-Cpp/MinGW32/include"
BIN      = danasah506.exe
CXXFLAGS = $(CXXINCS) -Ofast -m32 -Wall -Wextra -pedantic -Werror -Wfatal-errors
CFLAGS   = $(INCS) -ffunction-sections -fomit-frame-pointer -flto -w -s -fprofile-use -Ofast -m32 -Wall -Wextra -pedantic -Werror -Wfatal-errors
RM       = rm -f

.PHONY: all all-before all-after clean clean-custom

all: all-before $(BIN) all-after


clean: clean-custom
	${RM} $(OBJ) $(BIN)

$(BIN): $(OBJ)
	$(CC) $(LINKOBJ) -o $(BIN) $(LIBS)

aleatorio.o: aleatorio.c
	$(CC) -c aleatorio.c -o aleatorio.o $(CFLAGS)

atacado.o: atacado.c
	$(CC) -c atacado.c -o atacado.o $(CFLAGS)

busqueda.o: busqueda.c
	$(CC) -c busqueda.c -o busqueda.o $(CFLAGS)

danasah.o: danasah.c
	$(CC) -c danasah.c -o danasah.o $(CFLAGS)

egbb.o: egbb.c
	$(CC) -c egbb.c -o egbb.o $(CFLAGS)

entradas.o: entradas.c
	$(CC) -c entradas.c -o entradas.o $(CFLAGS)

evalua.o: evalua.c
	$(CC) -c evalua.c -o evalua.o $(CFLAGS)

fen.o: fen.c
	$(CC) -c fen.c -o fen.o $(CFLAGS)

generamovimientos.o: generamovimientos.c
	$(CC) -c generamovimientos.c -o generamovimientos.o $(CFLAGS)

hash.o: hash.c
	$(CC) -c hash.c -o hash.o $(CFLAGS)

leer_archivo_ini.o: leer_archivo_ini.c
	$(CC) -c leer_archivo_ini.c -o leer_archivo_ini.o $(CFLAGS)

libro.o: libro.c
	$(CC) -c libro.c -o libro.o $(CFLAGS)

salidas.o: salidas.c
	$(CC) -c salidas.c -o salidas.o $(CFLAGS)

see.o: see.c
	$(CC) -c see.c -o see.o $(CFLAGS)

test.o: test.c
	$(CC) -c test.c -o test.o $(CFLAGS)

variables.o: variables.c
	$(CC) -c variables.c -o variables.o $(CFLAGS)

xboard.o: xboard.c
	$(CC) -c xboard.c -o xboard.o $(CFLAGS)


User avatar
asanjuan
Posts: 211
Joined: Thu Sep 01, 2011 3:38 pm
Location: Seville, Spain

Re: Steps to compile for Android

Post by asanjuan » Wed Mar 19, 2014 11:20 pm

Thanks Pedro.
I downloaded the version for the ARM EABI platform. Is it the right one?

User avatar
pedrox
Posts: 992
Joined: Fri Mar 10, 2006 5:07 am
Location: Basque Country (Spain)
Contact:

Re: Steps to compile for Android

Post by pedrox » Thu Mar 20, 2014 7:13 am

If you're working in Windows, on the installation folder (bin?) of the program you will find the following file:

arm-none-linux-gnueabi-gcc.exe

Although the word linux, it compiles C and C++ files under windows to Android.

The truth is that it's easy to get confused with the version, I also have ever installed another and every time I do an update I have doubts.

I think you have to go to Codebench Sourcery Lite Edition for ARM GNU / Linux.

http://www.mentor.com/embedded-software ... ition/form

Then you choose whether you want to work on Windows or Linux.

I remember that was so, but I am not entirely sure.

User avatar
velmarin
Posts: 1600
Joined: Mon Feb 21, 2011 8:48 am

Re: Steps to compile for Android

Post by velmarin » Thu Mar 20, 2014 9:02 am

I installed the win 32 version, was distinguished as the exe file.
D:\Descargado\arm-2013.11-33-arm-none-linux-gnueabi.exe\

After download Danasah 506. (Makefiles included!!)
And all was right the first time.

thank you very much Pedro.

User avatar
asanjuan
Posts: 211
Joined: Thu Sep 01, 2011 3:38 pm
Location: Seville, Spain

Re: Steps to compile for Android

Post by asanjuan » Tue Mar 25, 2014 10:29 am

It seems that my code is not portable at all. :?
Still a lot of work to be done.

Now that I have the tools, is just a matter of time.

Thank you very much.

Regards.

User avatar
JuLieN
Posts: 2948
Joined: Mon May 05, 2008 10:16 am
Location: Nantes (France)
Contact:

Re: Steps to compile for Android

Post by JuLieN » Tue Mar 25, 2014 11:31 am

asanjuan wrote:Hi all,
My friends are asking me when I'm going to make an android version of my UCI engine Rhetoric. I wonder which are the steps to build such version because I've never compiled anything to that platform.

do I have to change something in the uci protocol?
is so simple as compile for the arm processor?
Is there a tutorial? Any reference guide?

I need a hint.

Thanks in advance.
I compile directly on my Android device, using CCTools. :) That's where the Android build of Senpai comes from, for instance.

https://play.google.com/store/apps/deta ... tools.free
"The only good bug is a dead bug." (Don Dailey)
Image [Blog: http://tinyurl.com/predateur ] [Facebook: http://tinyurl.com/fbpredateur ] [MacEngines: http://tinyurl.com/macengines ]

User avatar
asanjuan
Posts: 211
Joined: Thu Sep 01, 2011 3:38 pm
Location: Seville, Spain

Re: Steps to compile for Android

Post by asanjuan » Tue Mar 25, 2014 11:56 am

JuLieN wrote:
asanjuan wrote:Hi all,
My friends are asking me when I'm going to make an android version of my UCI engine Rhetoric. I wonder which are the steps to build such version because I've never compiled anything to that platform.

do I have to change something in the uci protocol?
is so simple as compile for the arm processor?
Is there a tutorial? Any reference guide?

I need a hint.

Thanks in advance.
I compile directly on my Android device, using CCTools. :) That's where the Android build of Senpai comes from, for instance.

https://play.google.com/store/apps/deta ... tools.free
That's cool! because I have an android TV box, so I even can edit in a big screen for android, while I'm sitting in my sofa !

I can't wait to get home and install it on my TV!
Thank you so much!

Android has brought a world of posibilities to work, enjoy, or even compile your own programs! And everything in a device that fits in a hand. It's amazing.

Post Reply