Recent

Author Topic: Target Android branch  (Read 25006 times)

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Target Android branch
« on: July 03, 2012, 11:09:39 am »
Hello,

I wonder if anyone has tested already the targetandroid branch: http://svn.freepascal.org/cgi-bin/viewvc.cgi/branches/targetandroid/

I am thinking of trying to built it with my FPC 2.6.0 as starting compiler and see if it can run LCL-CustomDrawn-Android

Any previous experience with it would be nice =)

I have commit rights, so I can apply fixes if people have patches for it.

thanks,

Felipe

Andru

  • Full Member
  • ***
  • Posts: 112
    • Homepage
Re: Target Android branch
« Reply #1 on: July 03, 2012, 11:32:06 am »
As I remember the comments for this branch, there was included patch based on mine for threads and some fixes from BeRo, so it should work :) But this depends on which revision of FPC 2.6.0 is used as a base, because revisions after 20768 are broken.

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: Target Android branch
« Reply #2 on: July 03, 2012, 12:01:40 pm »
But this depends on which revision of FPC 2.6.0 is used as a base, because revisions after 20768 are broken.

2.6.0 has only 1 revision since it is a release

barlone

  • New Member
  • *
  • Posts: 44
Re: Target Android branch
« Reply #3 on: July 03, 2012, 01:28:15 pm »
Does this mean that this branch can replace fpc4android?

Andru

  • Full Member
  • ***
  • Posts: 112
    • Homepage
Re: Target Android branch
« Reply #4 on: July 03, 2012, 03:26:08 pm »
Quote
2.6.0 has only 1 revision since it is a release
oops, I mean 2.6.x :)

Kostas

  • New Member
  • *
  • Posts: 30
Re: Target Android branch
« Reply #5 on: July 03, 2012, 08:37:38 pm »
I am trying to compile the targetandroid branch using this script:

SET PATH=c:\lazarus\fpc\2.6.1\bin\i386-win32\
make clean
make crossinstall CPU_TARGET=arm OS_TARGET=linux OPT="-dFPC_ARMEL" CROSSOPT="-CpARMv6 -CfVFPv3" CROSSBINDIR=C:\android\android-ndk-r7\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\bin OPT=-dFPC_ARMEL BINUTILSPREFIX=arm-linux-androideabi- INSTALL_PREFIX=C:\FPC4ANDROID\targetandroid\output
pause


But i get the following error:
Fatal: Can't find unit objpas used by MacPas
Fatal: Compilation aborted

Any idea?

Kostas

EDIT:
I also changed the PATH to show at the 2.6.0 compiler.
Now i get this errors:

make[3]: Entering directory `C:/FPC4ANDROID/targetandroid/packages'
make[3]: Nothing to be done for `clean'.
make[3]: Leaving directory `C:/FPC4ANDROID/targetandroid/packages'
make[2]: Leaving directory `C:/FPC4ANDROID/targetandroid'
make utils_clean FPC=C:/FPC4ANDROID/targetandroid/compiler/ppcrossarm.exe
make[2]: Entering directory `C:/FPC4ANDROID/targetandroid'
make -C utils clean
make[3]: *** No rule to make target `clean'.  Stop.
make[3]: Entering directory `C:/FPC4ANDROID/targetandroid/utils'
make[3]: Leaving directory `C:/FPC4ANDROID/targetandroid/utils'
make[2]: *** [utils_clean] Error 2
make[2]: Leaving directory `C:/FPC4ANDROID/targetandroid'
make[1]: *** [build-stamp.arm-linux] Error 2
make[1]: Leaving directory `C:/FPC4ANDROID/targetandroid'
make: *** [crossinstall] Error 2


EDIT 2:
As i found out the parameter OS_TARGET=linux should be OS_TARGET=android

EDIT 3:
I found with google the following:
How to compile:
---------------

from the command line, e.g. by issuing

make zipinstall FPC=<host fpc compiler> OS_TARGET=android CPU_TARGET=arm
CROSSOPT="-Cfsoft" BINUTILSPREFIX=<prefix-to-android-ndk-as-ld>

you should get a nice archive with your cross compiler after completion.

Before that you might need to create a new "fpcmake" tool by e.g.
building a normal zipinstall to be used during building the
crosscompiler (or native compiler) and put it into the path.

But i can not start a lot  with it...
« Last Edit: July 03, 2012, 09:13:11 pm by Kostas »

Kostas

  • New Member
  • *
  • Posts: 30
Re: Target Android branch
« Reply #6 on: July 03, 2012, 11:25:11 pm »
I managed to compile the fixed_2_6 branch.
But when i compile i get an error message:
Illegal parameter: -WR

Anyone knows what this means?

Kostas

EDIT: I found it out. I should uncheck the compiler option Unit style
« Last Edit: July 03, 2012, 11:29:37 pm by Kostas »

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: Target Android branch
« Reply #7 on: July 07, 2012, 09:54:17 am »
I managed to compile the fixed_2_6 branch.

fixes_2_6 does not contain the apropriate fixes for Android, AFAIK

In my Mac OS X I did the following:

svn co http://svn.freepascal.org/svn/fpc/branches/targetandroid targetandroid

and then:

make crossinstall CPU_TARGET=arm OS_TARGET=android OPT="-dFPC_ARMEL" CROSSOPT="-CpARMv6 -CfSoft" CROSSBINDIR=/Users/felipe/Programas/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin OPT=-dFPC_ARMEL BINUTILSPREFIX=arm-linux-androideabi- INSTALL_PREFIX=output

And it fails ... I'll ask in FPC-Devel mailling list.

/Users/felipe/Programas/targetandroid/compiler/ppcrossarm -Ur -Tandroid -Parm -XParm-linux-androideabi- -Xr -Ur -Xs -O2 -n -Fi../inc -Fi../arm -Fi../unix -Fiarm -Fi../linux -Fi../linux/arm -FD/Users/felipe/Programas/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin -FE. -FU/Users/felipe/Programas/targetandroid/rtl/units/arm-android -dFPC_ARMEL -darm -dRELEASE -CpARMv6 -CfSoft -Us -Sg ../linux/system.pp
arm.inc(906,2) Error: Unrecognized opcode rev
arm.inc(906,6) Error: Assembler syntax error
arm.inc(921,2) Error: Unrecognized opcode rev
arm.inc(921,6) Error: Assembler syntax error
arm.inc(946,2) Error: Unrecognized opcode rev
arm.inc(946,6) Error: Assembler syntax error
arm.inc(947,2) Error: Unrecognized opcode rev
arm.inc(947,6) Error: Assembler syntax error
arm.inc(973,2) Error: Unrecognized opcode rev
arm.inc(973,6) Error: Assembler syntax error
arm.inc(974,2) Error: Unrecognized opcode rev
arm.inc(974,6) Error: Assembler syntax error
text.inc(1774,14) Warning: Implicit string type conversion from "AnsiString" to "UnicodeString"
text.inc(1998,44) Warning: Implicit string type conversion with potential data loss from "UnicodeString" to "AnsiString"
system.pp(380) Fatal: There were 12 errors compiling module, stopping
Fatal: Compilation aborted
make[4]: *** [system.ppu] Error 1
make[3]: *** [android_all] Error 2
make[2]: *** [rtl_all] Error 2
make[1]: *** [build-stamp.arm-android] Error 2
make: *** [crossinstall] Error 2

Kostas

  • New Member
  • *
  • Posts: 30
Re: Target Android branch
« Reply #8 on: July 07, 2012, 01:21:59 pm »
I have managed to compile target android.
If i remember right you have to use android NDK r8
or at least copy the assembler arm-linux-androideabi-as from the revision r8 to the revision r7 and to the fpc path.
I will try it once more in order to be sure.

But even so, i was not able to compile the androidlcl example.
I will give it again a try and let you know what the error messages were.
Maybe you have then an idea how to solve them

EDIT: I had to build the fpcmake.exe tool with the sources of targetandroid before you can compile the targetandroid.

But will then your fixes be available then???

Although i could compile androidlcl example with the 2.6 fixes the examble crashes immediately in android...

I have done the thread patches from 2.6 fixes to your 2.5.1 sources but the application still crashes when a thread is created...
Maybe there is a problem in the lcl??

EDIT2: Sorry i was wrong about the ndk r8...
I have done so many changes installed and reinstalled so many time lazarus and i don' t remember right was i had done...
I will try it again from the beginning and i will post my results...

Kostas
« Last Edit: July 07, 2012, 02:00:03 pm by Kostas »

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: Target Android branch
« Reply #9 on: July 07, 2012, 01:52:36 pm »
The maintainer of the branch said he will try to fix the problem that I had building.

But will then your fixes be available then???

No idea. Once I can build it then I will check that and if necessary make commits.

I wonder how you managed to build it. Maybe you removed the options ARMv6? Because it is the responsible for causing the fail for me. But without it, it will crash on some devices.

Quote
Although i could compile androidlcl example with the 2.6 fixes the examble crashes immediately in android...

Like I said, 2.6.x is not suitable for Android development.

Quote
I have done the thread patches from 2.6 fixes to your 2.5.1 sources but the application still crashes when a thread is created...
Maybe there is a problem in the lcl??

I don't think so, the LCL is not involved in the threading. I have no idea what the problem could be, however.
« Last Edit: July 07, 2012, 11:01:45 pm by felipemdc »

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
Re: Target Android branch
« Reply #10 on: July 07, 2012, 02:05:03 pm »
@Kostas
FYI, I have tried with the ndk-r8 and the same error as Felipe did.
FPC 2.6.0

Andru

  • Full Member
  • ***
  • Posts: 112
    • Homepage
Re: Target Android branch
« Reply #11 on: July 07, 2012, 03:09:51 pm »
You can try to use this precompiled version of FreePascal from fixes_2_6 branch built with mine set of patches(compiler is built with options -CpARMv6 -CfSOFT). It works like a charm for me :) But I use threads via BeginThread function and set of RTL* functions for events and critical sections, so I can't guarantee that it will work with TThread class and AndroidLCL code. For better understanding what is wrong try to use Android 4.0 in emulator. In this version logcat finally can show what symbols are unresolved, and this is very helpful.

Kostas

  • New Member
  • *
  • Posts: 30
Re: Target Android branch
« Reply #12 on: July 07, 2012, 11:08:18 pm »
As i said before i was wrong about compiling targetandroid with the use of ndk r8.

But the NDK r8 helped me about something else:
It is the only way to compile the android branch 2.5.1 using the fpu with the options -CpARMv6 -CfVFPv2.
I get then a build without errors.
I put then the ppccrossarm.exe in the 2.6.1 bin directory and the units directory in the directory 2.5.1 exactly as i did it when with compiling with -CfSOFT.

But when i try to compile my androidlcl examble i get the error:
fcllaz.pas(0,0) Fatal: Can not find system used by fcllaz, ppu=..\..\fpc\2.5.1\units\arm-linux\rtl\system.ppu

But the system.ppu exists(!) in this directory.

Any idea?
Kostas

Kostas

  • New Member
  • *
  • Posts: 30
Re: Target Android branch
« Reply #13 on: July 08, 2012, 12:11:15 am »
What i forgot to mention before is that i had problems with my antivirus program (Avast).
When a new exe file was build while making the android branches it was opened in the sandbox which caused problems...

So i always need to turn the antivirus program off when i am making a build.

Maybe other antivirus programs have same or similar problems...

Kostas

Leledumbo

  • Hero Member
  • *****
  • Posts: 8111
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Target Android branch
« Reply #14 on: July 08, 2012, 05:13:06 am »
Quote
But when i try to compile my androidlcl examble i get the error:
fcllaz.pas(0,0) Fatal: Can not find system used by fcllaz, ppu=..\..\fpc\2.5.1\units\arm-linux\rtl\system.ppu

But the system.ppu exists(!) in this directory
fpc.cfg please... (just the -Fu lines)
and to ensure, compile with -vt and look for first lines containing "Using unit path...". make sure they point to your 2.5.1 units directory.