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