Hey guys,
I've ran into an issue here during my android expiriments.
I want to cross compile a library dpr to ARM to be able to use it with JNI on android. Below you will see a tiny example that reproduces the problem I'm facing now:
library hellojni;
uses
SysUtils,
JNI;
function Java_com_example_hellojni_HelloJni_stringFromJNI(PEnv: PJNIEnv; this: JObject): JString;
begin
Result := (PEnv^).NewStringUTF(PEnv, 'Hello from JNI !');
end;
exports Java_com_example_hellojni_HelloJni_stringFromJNI;
end.
When I use the following command (please yell if this command is wrong somehow):
fpc -Tlinux -Parm -XParm-linux- hello-jni.dpr
I get:
Free Pascal Compiler version 2.7.1 [2011/10/27] for arm
Copyright (c) 1993-2011 by Florian Klaempfl and others
Target OS: Linux for ARMEL
Compiling hello-jni.dpr
Assembling hellojni
Linking libhello-jni.so
/usr/local/bin/arm-linux-ld: warning: link.res contains output sections; did you forget -T?
/usr/local/bin/arm-linux-ld: cannot find /lib/ld-linux.so.3
hello-jni.dpr(9,60) Error: Error while linking
hello-jni.dpr(9,60) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/local/bin/ppcarm returned an error exitcode (normal if you did not specify a source file to be compiled)
So there is a /lib/ld-linux.so.3 file which is nowhere to be found.
ls -al /lib | grep ld
gives
-rwxr-xr-x 1 root root 113964 Jan 22 2011 ld-2.11.1.so
lrwxrwxrwx 1 root root 12 Feb 2 2011 ld-linux.so.2 -> ld-2.11.1.s
So I only have version 2. I'm running Ubuntu 10.04 here.
Some extra research led me to the following website:
http://wiki.maemo.org/Compile_FreePascal_on_deviceWhich mentions the t_linux.pas, which is part of FPC, and refers to ld-linux.so.3. The source:
{$ifdef arm}
{$ifdef FPC_ARMEL}
defdynlinker:='/lib/ld-linux.so.3';
{$else FPC_ARMEL}
defdynlinker:='/lib/ld-linux.so.2';
{$endif FPC_ARMEL}
{$endif arm}
So in my case FPC_ARMEL is defined, so it selects v3. This makes sense, because this is how I've build my cross compiler:
http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARMsudo make crossinstall CPU_TARGET=arm OS_TARGET=linux CROSSBINDIR=/home/user/lazarus/fpc/binutils/ OPT=-dFPC_ARMEL INSTALL_PREFIX=/usr
So what's up here? Should I just dive in the source and change the number and rebuild my ppcarm?
Please help me find the best solution here.
Thanks a bunch!
Can somebody please help me out here? I'm almost there.
Thanks!