Sign in Join

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

Mailing lists / fpc-pascal / 2011-02

Android calling JNI functions crash

6 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

de_jean_7777

Under Android I've tried running my native programs which works great. However, If I try to call any of the JNI functions as received with env (PJNIEnv, as the first argument of any native JNI function) I get a crash. I've checked the pointers and they are not nil, but from what I've been able to gather I get a SIGILL, ILLOPCODE signal. At first I thought I may have targeted the wrong cpu or fpu instruction set, so I've targeted ARMv3 for cpu and SOFT for fpu, rebuilt the crosscompiler but still no luck as I get the same crash. I'm not sure why this is happening as I'm using FPU instruction in my program, and they work. I've built the crosscompiler using the source from trunk also with a compiler built from trunk. The headers I use for this were provided by Benjamin Rosseaux with his Android JNI example, and the BeRoXM app, who seems to have it working. Any help would be appreciated. I've checked also and made a simple JNI test program, which also crashes, so I'm suspecting it might have something to do with the crosscompiler or something blatant I've missed.

I've been at this last night for about 8 hours and am slowly going insane.

Reply by email

de_jean_7777
to de_jean_7777

I've also forgot to mention the crosscompiler is a i386-win (under XP).

Show quoted text 23 lines
Under Android I've tried running my native programs which works great. However, If I try to call any of the JNI functions as received with env (PJNIEnv, as the first argument of any native JNI function) I get a crash. I've checked the pointers and they are not nil, but from what I've been able to gather I get a SIGILL, ILLOPCODE signal. At first I thought I may have targeted the wrong cpu or fpu instruction set, so I've targeted ARMv3 for cpu and SOFT for fpu, rebuilt the crosscompiler but still no luck as I get the same crash. I'm not sure why this is happening as I'm using FPU instruction in my program, and they work. I've built the crosscompiler using the source from trunk also with a compiler built from trunk. The headers I use for this were provided by Benjamin Rosseaux with his Android JNI example, and the BeRoXM app, who seems to have it working. Any help would be appreciated. I've checked also and made a simple JNI test program, which also crashes, so I'm suspecting it might have something to do with the crosscompiler or something blatant I've missed. I've been at this last night for about 8 hours and am slowly going insane. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

de_jean_7777
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote
I use eabi=5 (aka ARMv5), just in case this is the problem. But I don't use JNI.

I've tried 4 different toolchains: CodeSourcery ones, NDK ones (ld crashes), WinARM (cannot get it to work, something about different EABI's when linking), and YAGARTO. Both YAGARTO and CodeSourcery will allow linking, and the code works, I can even call the android log routines, everything except the JNI functions over the env(PJNIEnv) parameter. Does anyone have any tips on building an arm-linux crosscompiler for i386-win32, as I mostly only find Linux examples. I've not seen anyone using a window cross-compiler. Does specifying ARMv5 as instruction set get me EABI=5 or do I have to set this some other way?

Reply by email

de_jean_7777
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 7 lines
No idea, I always use Linux, but if no-one has a better idea, I would suggest that you try first using the linux cross-compiler, just to check if the crash is really related to the binutils. There are some instructions here: http://wiki.lazarus.freepascal.org/Android_Interface#Configuring_the_Free_Pascal_Compiler_for_Android

I've successfully created a win32 crosscompiler. It was a matter of passing the right parameters to as and ld which required creating hook scripts (actually programs), and using the appropriate binutils, in this case YAGARTO, but CodeSourcery ones should work too (did not test). Luckily, Benjamin Rosseaux helped me with this or I've would have been stuck at for longer. For gnu as I've passed the following parameters in the as hookscript '-march=armv6 -meabi=5' and of course when compiling the crosscompiler and programs the '-CpARMv6 -CfSOFT' parameters need to be passed to fpc. I don't think there are any special parameters required for ld, at least not for ARMv6 CPUs.

Reply by email