Problem on linking .so (shared library)

I have two projects, the first one(A) is application which linked to the second one(B) which is type of shared library.
Project A : Android.Tegra
Project B : dy

in Project B I have declared a simple class with extern function and I want to use this class in the main class of Project A.
I set up the additional Include Directories and also Additional Library Directories and set up Additional Dependencies as following “android;dy;” and finally add a Reference of Project B(dy) to Project A.
Everything built fine, and deployed on Shield device, but application crashed. and I’ve got an error at Android log that said can not load native library or something similar to it.
I can successfully link static library(.a) and run application without any problem but I don’t know why application with shared library doesn’t work.
Also I added the library as additional dependencies of ANT Build, but it wont work :(
Can anybody help me on this issue?

Thanks
Pooya

Hi PooyaEimadar,

It seems some mistakes in lib name in your loading part code just like misspell or Case sensitivity issue.
if your lib name is “libXXXXXX”. the java loading code should like below:

public native String  stringFromJNI();
  
    static {
        System.loadLibrary("XXXXXX");
    }

And make sure the lib .so has been packed into the APK. you can unzip the APK to check it. (APK is just zip package). It should be like lib//libXXXXXX.so.

Victor

Thanks you for your reply.
Both projects are pure native code without JAVA code. the APK has the my library.so, I doubled check the name and case sensitive.
I also use dlopen in c++ but the function always returns 0.

void* __shared = dlopen("dy.so", RTLD_NOW | RTLD_LOCAL);

Should I load library only in JAVA code?

There are two ways to do this:

load in java code : see above.
load in native code: you have to use the absolute addr “/data/data//lib/dy.so”.

Victor

Thanks for your consideration Victor.
Kind Regrads