1

I'm essentially trying to follow a SO solution described here, but am running into a problem.

This is essentially what I am doing fron inside a JNI library:

handle = dlopen("/data/data/lib/my.package/lib/myLibrary.so", RTLD_LAZY);
myFunctionName = (func)dlsym(handle, "main");
(*myFunctionName)(numberOfArgs, arguments);

The problem is that the above ONLY succeeds if

System.loadLibrary("myLibrary")

is called from the same Java code invoking the JNI. But this obviously defeats the purpose of loading the library via dlopen.

All I get from LocCat is

A/libc(29472): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1)

What is going wrong? Is it something to do with the build parameters for myLibrary.so?

Community
  • 1
  • 1
Cigogne Eveillée
  • 2,178
  • 22
  • 36
  • 1
    Just to know, why would you want to load a library in native code with dlopen instead of using System.loadLibrary? – Esparver Mar 06 '13 at 10:43
  • To address this problem: http://stackoverflow.com/questions/10649119/calling-native-method-twice-of-third-party-library-in-an-activity-causes-the-and – Cigogne Eveillée Mar 06 '13 at 15:00

1 Answers1

1

After using dlerror() to diagnose the problem, I actually found that dlopen was failing. Turns the path was wrong. It should be:

handle = dlopen("/data/data/my.package/lib/myLibrary.so", RTLD_LAZY);
Cigogne Eveillée
  • 2,178
  • 22
  • 36