Système.loadLibrary ne fonctionne pas. UnsatisfiedLinkError pour la deuxième lib dans la chaîne d'

J'ai un programme en java Client.class qui utilise rpc bibliothèque partagée libclient.donc via JNI.
libclient.ainsi est construit, partagé et utilise rpc bibliothèque partagée libhttp..

libclient.donc, et libhttp.ainsi sont placés dans le dossier /home/client/lib64

Client.class est placé dans /home/client/bin

Client peut charger la bibliothèque avec

  1. Système.de la charge et de la variable d'environnement LD_LIBRARY_PATH
  2. Système.loadLibrary et -Djava.de la bibliothèque.chemin

La première méthode fonctionne très bien.

export LD_LIBRARY_PATH = /home/client/lib64

java -classpath ./bin Client

La seconde façon échoue.

java -classpath ./bin -Djava.library.path=./../lib64 Client

java.lang.UnsatisfiedLinkError: /home/client/lib64/libclient.so: libhttp.so: cannot open shared object file: No such file or directory

Quand j'ai mis libhttp.donc dans /usr/lib64 la deuxième façon fonctionne très bien.

Pourquoi libclient.donc, est à la recherche d'libhttp.donc dans /usr/lib64 si j'utilise du Système.loadLibrary?
Comment puis-je résoudre ce problème sans faire face libhttp.donc dans /usr/lib64?

Mon code de chargement:

    //Try load from -Djava.library.path        
    boolean found = false;
    String lib = "client";
    try {
       System.loadLibrary(lib);
       found = true;
    } catch (UnsatisfiedLinkError e) {
       e.printStackTrace();
    }
    //Try load from LD_LIBRARY_PATH
    if (!found) {
       lib = "libclient.so";
       String ld_lib_path = System.getenv("LD_LIBRARY_PATH");
       String[] paths = ld_lib_path.split(":");
       for(int i=0; i<paths.length; i++) {
          String p = paths[i];
          File x = new File(p, lib);
          if (x.exists()) {
             System.load(x.getAbsolutePath());
             found = true;
             break;
          }
       }
    }

Des informations supplémentaires.

Si je test libclient.donc, avec ldd puis je vois: libhttp.donc => pas trouvé
Si j'ai mis export LD_LIBRARY_PATH = /home/client/lib64 puis je vois: libhttp.donc => /home/client/lib64/libhttp.donc

OriginalL'auteur degratnik | 2013-04-25