Page 1 of 1

How to use 3rd party library on android?

Posted: Sat Jun 08, 2019 10:04 am
by Ruben776
I have hard time fnding out how to load and use compiled .so library in firemonkey application. I've managed to setup project in a way that it compiles and library is bundled in apk but can't load it when application starts. Is system.LoadLibrary() enough or do I need some java wrapper for the lib?

edit: my code looks like this now, still can't get past library loading stage. TPath.GetLibraryPath returns correct path to where library is located ( I checked with adb pull)

Code: Select all

    LIBNAME = 'sunvox.dll';
    LIBNAME = '';

function sv_load_dll:integer;
var libPath:system.string;
  g_sv_dll:= 0 ;
  g_sv_dll:=dlopen(MarshaledAString(libPath), RTLD_LAZY);
  g_sv_dll := LoadLibrary(MarshaledString(libPath));
  if( g_sv_dll = 0 )then exit;

  sv_audio_callback:=tsv_audio_callback(import('sv_audio_callback' ));

Re: How to use 3rd party library on android?

Posted: Sat Jun 08, 2019 8:10 pm
by NightRadio
So what exactly is the problem? Some errors?
Please check the android/sample_project/SunVox Player sources.
It the library is loaded by system.LoadLibrary(), then you need to call init(), open_slot(), etc.