[fpc-pascal] Android and cwstring

Torsten Bonde Christiansen tc at epidata.info
Wed Jul 31 15:11:15 CEST 2013


Hi,

I'm trying to create a library for use in an android application, but 
i'm having a hard time getting it to work correctly.

More specifically i cannot get the library to use the "cwstring" unit. 
Below you see a working example of a library that works fine (the log 
entry is generated) when cwstring i commented out, but when included the 
android application just hangs on the message:

07-31 16:52:16.284: D/dalvikvm(338): Trying to load lib 
/data/data/dk.epidata.epidatatestproject/lib/libepitest.so 0x45f3e268

The error is most likely mine, my experience with android programming 
and libraries are limited, but I fail to see what I am doing wrong in 
this case.

Just for record i use:
torsten at Rainier:~$ ppcrossarm -i
Free Pascal Compiler version 2.7.1

Compiler Date      : 2013/07/25
Compiler CPU Target: arm

Settings for android in .fpc.cfg:
-CfVFPV3

#ifdef cpuarm
-Xd
-FD/home/torsten/AndroidDev/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin
-Fl/home/torsten/AndroidDev/android-ndk-r8e/platforms/android-14/arch-arm/usr/lib
-XParm-linux-androideabi-
#endif


Regards,
Torsten B. Christiansen.

====== library code ======

library project1;

{$mode objfpc}{$H+}

uses
   jni,      // jni from packages/jni/src/jni.pas
   cmem,     // includin  cmem makes no difference
   cwstring  // including cwstring make the library halt on load... :(
   ;

const
   ANDROID_LOG_INFO=4;

function LOGI(prio:longint;tag,text:pchar):longint; cdecl; varargs; 
external 'liblog.so' name '__android_log_print';

function JNI_OnLoad(vm:PJavaVM;reserved:pointer):jint; cdecl;
begin
   result:=JNI_VERSION_1_6;
end;

exports
   JNI_OnLoad;

begin
   LOGI(ANDROID_LOG_INFO, 'libepitest.so', 'Init Library');
end.




More information about the fpc-pascal mailing list