Recent

Author Topic: crosscompile for android  (Read 16882 times)

herux

  • Full Member
  • ***
  • Posts: 102
crosscompile for android
« on: March 28, 2011, 07:01:33 am »
Hi all,
please help me with the following error,
I try to arm crosscompile for android OS. only a HelloWorld project that uses dynlibs.pas unit.


/helloworld$ ppcarm -Tlinux -O- -XP -Xd -Fu/usr/share/fpcsrc/rtl/units/arm-linux/ -FD/usr/share/fpcsrc/binutils/  helloworld.lpr
Free Pascal Compiler version 2.5.1 [2011/03/24] for arm
Copyright (c) 1993-2010 by Florian Klaempfl
Target OS: Linux for ARMEL
Compiling helloworld.lpr
Assembling helloworld
Compiling resource helloworld.or
Linking helloworld
/usr/share/fpcsrc/rtl/units/arm-linux/cprt0.o: In function `_start':
(.text+0x4c): undefined reference to `__libc_start_main'
/usr/share/fpcsrc/rtl/units/arm-linux/cprt0.o: In function `_haltproc_eabi':
(.text+0x88): undefined reference to `_fini'
/usr/share/fpcsrc/rtl/units/arm-linux/cprt0.o: In function `_haltproc_eabi':
(.text+0x90): undefined reference to `_init'
/usr/share/fpcsrc/rtl/units/arm-linux/dl.o: In function `DL_init':
/usr/share/fpcsrc/rtl/linux/../unix/dl.pp:100: undefined reference to `dladdr'
helloworld.lpr(80) Error: Error while linking
helloworld.lpr(80) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
I use a cross library of android NDK

thanks

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: crosscompile for android
« Reply #1 on: March 28, 2011, 11:48:33 am »
How have you installed FPC? Which instructions have you followed to do that?

What is the source code of your test program?

herux

  • Full Member
  • ***
  • Posts: 102
Re: crosscompile for android
« Reply #2 on: March 28, 2011, 12:47:49 pm »
Thanks for the replay

I follows this http://wiki.lazarus.freepascal.org/Cross_compiling
or this http://alexmogurenko.com/blog/programming/android-building-free-pascal-compiler-for-android/
both links produce the same error
here is my helloworld code that work:
Code: [Select]
program helloworld;
begin
  writeln('Hello android from freepascal');
end.

and here is the code that error on compile,
Code: [Select]
program helloworld;
uses dynlibs;
begin
  writeln('Hello android from freepascal');
end.


I found this link http://honeypod.blogspot.com/2007/12/initialize-libc-for-android.html
but I don't understand yet, can someone explain it ?

EDIT:
Sorry, I am using
- ubuntu 10.04 x86_64.
- fpc from svn
- build ppcrossarm using cross binary binutils source or this http://www.codesourcery.com/

I have tried using the option -Xc to pass the linker and its compile succesfully, but if running on emulator or real device, i got "segmentation fault"
« Last Edit: March 28, 2011, 12:59:29 pm by herux »

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: crosscompile for android
« Reply #3 on: March 28, 2011, 01:40:15 pm »

herux

  • Full Member
  • ***
  • Posts: 102
Re: crosscompile for android
« Reply #4 on: March 29, 2011, 12:30:58 pm »
Hi @felipemdc
I have followed your instruction, but error still the same.
now I am using mandriva 2010 on virtualbox,

what should I do now?  %)

Laksen

  • Hero Member
  • *****
  • Posts: 745
    • J-Software
Re: crosscompile for android
« Reply #5 on: March 29, 2011, 01:18:26 pm »
Are you linking to the correct libraries, i.e have you copied the libraries from the target phone?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11453
  • FPC developer.
Re: crosscompile for android
« Reply #6 on: March 29, 2011, 01:24:13 pm »
Does this target have glibc or some embedded libc ?

herux

  • Full Member
  • ***
  • Posts: 102
Re: crosscompile for android
« Reply #7 on: March 29, 2011, 02:48:48 pm »
yes. I use the correct library. it's from android NDK (Native Development Kit) http://developer.android.com/sdk/ndk/index.html

there are some libraries there, namely libc.so libdl.so, libz.so etc.

 

TinyPortal © 2005-2018