frostwire / frostwire-jlibtorrent

A swig Java interface for libtorrent by the makers of FrostWire. Develop libtorrent based apps with the joy of coding in Java.
http://www.frostwire.com
MIT License
444 stars 137 forks source link

jlibtorrent UnsatisfiedLinkError #210

Closed asadsm closed 5 years ago

asadsm commented 5 years ago

I've gone through all the issues posted here regarding this but I haven't been able to solve it. I'm using gradle on Linux using IntelliJ IDEA so I added the following:

compile 'com.frostwire:jlibtorrent:1.2.0.18'

and then downloaded the jlibtorrent-linux jar, unpacked it and added the so. So the path looks something like this:

/home/asmalik/libs/libjlibtorrent-1.2.0.18.so

Now I added /home/asmalik/libs to my java library path but gives the following error:

Exception in thread "main" java.lang.LinkageError: Look for your architecture binary instructions at: https://github.com/frostwire/frostwire-jlibtorrent
    at com.frostwire.jlibtorrent.swig.libtorrent_jni.<clinit>(libtorrent_jni.java:33)
    at com.frostwire.jlibtorrent.swig.alert.<clinit>(alert.java:493)
    at com.frostwire.jlibtorrent.alerts.AlertType.<clinit>(AlertType.java:11)
    at com.frostwire.jlibtorrent.SessionManager.<clinit>(SessionManager.java:23)
    at Main.main(Main.java:7)
Caused by: java.lang.UnsatisfiedLinkError: no jlibtorrent in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1119)
    at com.frostwire.jlibtorrent.swig.libtorrent_jni.<clinit>(libtorrent_jni.java:27)
    ... 4 more

I even tried running it using the command line like this:

java -Djava.library.path=/home/asmalik/libs -cp torlib-1.0.jar Main but that didn't work. I also tried adding it as a NativeLibrary via Intellij IDEA but the same issue. I tried moving the .so inside the project directory and add that to the library.path but same result.

The output actually shows the library path being set:

java library path: /home/asmalik/libs
Exception in thread "main" java.lang.LinkageError: Look for your architecture binary instructions at: https://github.com/frostwire/frostwire-jlibtorrent
        at com.frostwire.jlibtorrent.swig.libtorrent_jni.<clinit>(libtorrent_jni.java:33)
        at com.frostwire.jlibtorrent.swig.alert.<clinit>(alert.java:493)
        at com.frostwire.jlibtorrent.alerts.AlertType.<clinit>(AlertType.java:11)
        at com.frostwire.jlibtorrent.SessionManager.<clinit>(SessionManager.java:23)
        at Main.main(Main.java:7)
Caused by: java.lang.UnsatisfiedLinkError: no jlibtorrent in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
        at java.lang.Runtime.loadLibrary0(Runtime.java:870)
        at java.lang.System.loadLibrary(System.java:1119)
        at com.frostwire.jlibtorrent.swig.libtorrent_jni.<clinit>(libtorrent_jni.java:27)
        ... 4 more

I also tried updating my bashrc with the following:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/asmalik/libs

and again....same issue.

Am I missing something really obvious here?

aldenml commented 5 years ago

I need to know your Linux distribution and architecture and also confirm that you are using the correct library architecture on it.

asadsm commented 5 years ago
CentOS release 6.5 (Final)
LSB_VERSION=base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
CentOS release 6.5 (Final)
CentOS release 6.5 (Final)

Using the following: com.frostwire:jlibtorrent-linux:1.2.0.18

Arch: Linux 2.6.32-431.11.2.el6.x86_64 #1 SMP Tue Mar 25 19:59:55 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

aldenml commented 5 years ago

Can you confirm that you using the 64 bit version of libjlibtorrent-1.2.0.18.so?

asadsm commented 5 years ago

Using the one under: /lib/x86_64 when I uncompress the jar. There is no .so file in the x86 folder

proninyaroslav commented 5 years ago

I got the same error from user of my app. There was a first case. P.S: 1.2.0.18-RC11 version

SER_COMMENT=
ANDROID_VERSION=4.4.2
APP_VERSION_NAME=1.8
BRAND=samsung
PHONE_MODEL=SM-N7505
CUSTOM_DATA=
STACK_TRACE=java.lang.LinkageError: Look for your architecture binary instructions at: https://github.com/frostwire/frostwire-jlibtorrent
at com.frostwire.jlibtorrent.swig.libtorrent_jni.<clinit>(libtorrent_jni.java:33)
at com.frostwire.jlibtorrent.swig.alert.<clinit>(alert.java:493)
at com.frostwire.jlibtorrent.alerts.AlertType.<clinit>(AlertType.java:11)
at com.frostwire.jlibtorrent.SessionManager.<clinit>(SessionManager.java:23)
at org.proninyaroslav.libretorrent.services.TorrentTaskService.init(TorrentTaskService.java:185)
at org.proninyaroslav.libretorrent.services.TorrentTaskService.onStartCommand(TorrentTaskService.java:411)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3025)
at android.app.ActivityThread.access$2200(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5692)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load jlibtorrent from loader dalvik.system.PathClassLoader[dexPath=/data/app/org.proninyaroslav.libretorrent-1.apk,libraryPath=/data/app-lib/org.proninyaroslav.libretorrent-1]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:358)
at java.lang.System.loadLibrary(System.java:526)
at com.frostwire.jlibtorrent.swig.libtorrent_jni.<clinit>(libtorrent_jni.java:27)
... 16 more
java.lang.UnsatisfiedLinkError: Couldn't load jlibtorrent from loader dalvik.system.PathClassLoader[dexPath=/data/app/org.proninyaroslav.libretorrent-1.apk,libraryPath=/data/app-lib/org.proninyaroslav.libretorrent-1]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:358)
at java.lang.System.loadLibrary(System.java:526)
at com.frostwire.jlibtorrent.swig.libtorrent_jni.<clinit>(libtorrent_jni.java:27)
at com.frostwire.jlibtorrent.swig.alert.<clinit>(alert.java:493)
at com.frostwire.jlibtorrent.alerts.AlertType.<clinit>(AlertType.java:11)
at com.frostwire.jlibtorrent.SessionManager.<clinit>(SessionManager.java:23)
at org.proninyaroslav.libretorrent.services.TorrentTaskService.init(TorrentTaskService.java:185)
at org.proninyaroslav.libretorrent.services.TorrentTaskService.onStartCommand(TorrentTaskService.java:411)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3025)
at android.app.ActivityThread.access$2200(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5692)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
aldenml commented 5 years ago

@asadsm can you run > ldd /home/asmalik/libs/libjlibtorrent-1.2.0.18.so and paste the output?

@proninyaroslav In my experience android has a weak update process with the native libraries, we mitigated it with the suffix of the library but we were still having some errors like that.

asadsm commented 5 years ago
ldd: warning: you do not have execution permission for `/home/asmalik/libs/libjlibtorrent-1.2.0.18.so'
/home/asmalik/libs/libjlibtorrent-1.2.0.18.so: /lib64/libc.so.6: version `GLIBC_2.16' not found (required by /home/asmalik/libs/libjlibtorrent-1.2.0.18.so)
/home/asmalik/libs/libjlibtorrent-1.2.0.18.so: /lib64/libc.so.6: version `GLIBC_2.17' not found (required by /home/asmalik/libs/libjlibtorrent-1.2.0.18.so)
/home/asmalik/libs/libjlibtorrent-1.2.0.18.so: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /home/asmalik/libs/libjlibtorrent-1.2.0.18.so)
        libm.so.6 => /lib64/libm.so.6 (0x00007ff4b6dbd000)
        libc.so.6 => /lib64/libc.so.6 (0x00007ff4b6a28000)
        /lib64/ld-linux-x86-64.so.2 (0x00007ff4b78b3000)
asadsm commented 5 years ago

Not a C++ developer but looks like that might be the issue?

proninyaroslav commented 5 years ago

@asadsm I think you have an incompatible version of glibc from your distibutive.

aldenml commented 5 years ago

yes, that's the problem, a missing or incompatible version of glibc. At this moment I have no way to help you with that in CentOS, I'm not familiar with that distribution or yum.

asadsm commented 5 years ago

Understood. Thanks for the quick help!