Directly call function in another .so file while in C++ code

I have a.so which defines void a() and b.so which defines void b(). They are both put in the .apk so they are available to the Android application.

Now suppose that I’m calling a() through JNI. Is it possible to call b() from a() while completely bypassing JNI?

Can I do it this way in Android (the code is only for illustration, so it might have some errors)?

void a() {
    void *handle = dlopen("b.so", RTLD_LAZY);
    void (*b)() = dlsym(handle, "b");
    b();
}

Would I need to add the fully qualified path?


Source: c++

Leave a Reply