Page 1 of 2

Steps to compile for Android

Posted: Wed Mar 19, 2014 11:17 am
by asanjuan
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.

Re: Steps to compile for Android

Posted: Wed Mar 19, 2014 1:19 pm
by pedrox
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.

Re: Steps to compile for Android

Posted: Wed Mar 19, 2014 4:33 pm
by flok
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)
...

Re: Steps to compile for Android

Posted: Wed Mar 19, 2014 6:48 pm
by pedrox
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)


Re: Steps to compile for Android

Posted: Thu Mar 20, 2014 12:20 am
by asanjuan
Thanks Pedro.
I downloaded the version for the ARM EABI platform. Is it the right one?

Re: Steps to compile for Android

Posted: Thu Mar 20, 2014 8:13 am
by pedrox
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.

Re: Steps to compile for Android

Posted: Thu Mar 20, 2014 10:02 am
by velmarin
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.

Re: Steps to compile for Android

Posted: Tue Mar 25, 2014 11:29 am
by asanjuan
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.

Re: Steps to compile for Android

Posted: Tue Mar 25, 2014 12:31 pm
by JuLieN
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

Re: Steps to compile for Android

Posted: Tue Mar 25, 2014 12:56 pm
by asanjuan
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.