Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-06

android basic question

6 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Thierry Bothorel

Hi,

Just a couple of questions. I wanted to play with android native development kit to see if I can replace the basic C "hello world" library from NDK samples with a fpc one. After "fighting" with cross compile, JNI headers, i'm stuck now with Android libc implementation (bionic).

After googling I did not found clear answers, but my understanding is that it is not possible to build natives libraries for Android without writing a completely new libc translation for bionic ?

Thierry Bothorel

Reply by email

Marco van de Voort
to Thierry Bothorel

In our previous episode, Thierry Bothorel said:

After googling I did not found clear answers, but my understanding is that it is not possible to build natives libraries for Android without writing a completely new libc translation for bionic ?

I don't fully understand. libc's are not translated into pascal.

Reply by email

Thierry Bothorel
to Marco van de Voort
Marco van de Voort wrote 9 lines
In our previous episode, Thierry Bothorel said: > After googling I did not found clear answers, but my understanding is > that it is not possible to build natives libraries for Android without > writing a completely new libc translation for bionic ? > I don't fully understand. libc's are not translated into pascal.

Well,

to me more clear, when I try to compile this :

Show quoted text 22 lines
library hellojni; {$mode objfpc}{$H+} uses //Classes { you can add units after this } JNI; {$R *.res} procedure Java_com_example_hellojni_HelloJni_stringFromJNI( PEnv: PJNIEnv; Obj: JObject); {$IFDEF WIN32} stdcall; {$ENDIF} {$IFDEF LINUX} cdecl; {$ENDIF} begin Writeln('Hello world from Freepascal!'); end; exports Java_com_example_hellojni_HelloJni_stringFromJNI; end.

I have errors in ...fpsrc/2.5.1/packages/libc/....

...

Show quoted text 8 lines
Assembling hellojni Compiling resource /home/thierrybo/Sys/Lazarus.projets/Tests/JNI/Hello-jni/lib/arm-linux/hellojni.or Linking /home/thierrybo/Sys/Lazarus.projets/Tests/JNI/Hello-jni/hello-jni.so /home/thierrybo/Sys/local/opt/fpc/cross/bin/arm-linux-ld: cannot find -lpthread hellojni.lpr(17,41) Error: Error while linking

after googling, it appears android libc is not standard. Here is an excerpt aboout a patch for Mono:

Show quoted text 13 lines
This is a series of patches to add support to Mono for building against the Android NDK [0]. Android runs the Linux kernel, but moves many things around compared to a "normal" desktop Linux distro. These patches are based against the mono-2-6 branch. This second patch patches libgc so that it will properly build and link under Android. In particular, note that Android includes pthread_*() functions within libc, not libpthread, thus the added configure check. * include/private/gcconfig.h: Android platforms are built atop Linux, don't use glibc, and uses `environ` instead of `__environ`. * configure.in: Use AC_CHECK_LIB() to check for pthread instead of just blindly linking to -lpthread, as Android includes pthread support within libc and doesn't provide a separate libpthread.

Thierry B

Reply by email

Jonas Maebe
to Thierry Bothorel
Thierry Bothorel wrote
I have errors in ...fpsrc/2.5.1/packages/libc/....

That package only works under Linux/i386, because it is only intended as a replacement for the Kylix libc unit. It cannot and will never work on any other platform. It is also not compiled by the Makefile for Linux/ARM. So it is normal that if you circumvent the makefile and try to compile the unit manually that it will not work.

Jonas

Reply by email

Thierry Bothorel
to Jonas Maebe
Jonas Maebe wrote
That package only works under Linux/i386, because it is only intended as a replacement for the Kylix libc unit. It cannot and will never work on any other platform. It is also not compiled by the Makefile for Linux/ARM. So it is normal that if you circumvent the makefile and try to compile the unit manually that it will not work. Jonas

OK,,

I started with Mathiew Mead JNI headers translation for Delphi/Kylix, that explains libc use. I did not found any JNI headers translation for Freepascal. Does this mean that the only solution is to update JNI.pas so that it uses Unix units instead of libc ?

Thierry B.

Reply by email

Jonas Maebe
to Thierry Bothorel
Thierry Bothorel wrote
I started with Mathiew Mead JNI headers translation for Delphi/Kylix, that explains libc use. I did not found any JNI headers translation for Freepascal. Does this mean that the only solution is to update JNI.pas so that it uses Unix units instead of libc ?

Yes, indeed.

Jonas

Reply by email