Search code examples
javajava-native-interfaceshared-librariesubuntu-12.04shared-objects

Unable to load .so file


I have an application which uses one native library "libSample.so" which is depend upon another .so file.I am trying to load that library using following code

File File1 = new File("libSample.so");

static
{
     try {
            System.load(File1.getAbsolutePath());

          } catch (UnsatisfiedLinkError e) {
            System.out.println("Link Error");
          }

 }

Before loading library I have tried setting up LD_LIBRARY_PATH where the library is located using command line.

export LD_LIBRARY_PATH=/home/usb:${LD_LIBRARY_PATH}

But still the library not get load. What should I do now? Please help.


Solution

  • static {
        System.loadLibrary("libSample.so");
    }
    

    I assumed that you have your jars in /libs directory and .so file in /libs/armeabi directory so the system finds them. You do not have to add .so files in your eclipse build path.