jni - java.lang.UnsatisfiedLinkError - loading multiple lib files? -


at first, error looked normal me, after trying known things, still have no luck running program. please let me explain in detail.

i trying run tc(tokyocabinet) example using tc's java api on ubuntu. both tc , tc-java got built , installed in home directory. (not /usr/local/lib).

i running program -

$ java -djava.library.path=/home/siddharth/tools/tc-java/lib -classpath ./bin/:lib/tokyocabinet.jar hdbtest 

and getting following error -

exception in thread "main" java.lang.unsatisfiedlinkerror: /home/siddharth/tools/tc-java/lib/libjtokyocabinet.so.1.1.0: /home/siddharth/tools/tc-java/lib/libjtokyocabinet.so.1.1.0: undefined symbol: tcversion  @ java.lang.classloader$nativelibrary.load(native method)  @ java.lang.classloader.loadlibrary0(classloader.java:1751)  @ java.lang.classloader.loadlibrary(classloader.java:1676)  @ java.lang.runtime.loadlibrary0(runtime.java:822)  @ java.lang.system.loadlibrary(system.java:993)  @ tokyocabinet.loader.load(loader.java:41)  @ tokyocabinet.hdb.<clinit>(hdb.java:37)  @ hdbtest.main(hdbtest.java:10) 

now, error symbol "tcversion". ran -

$ nm /home/siddharth/tools/tc-java/lib/libjtokyocabinet.so.1.1.0  | grep -i tcversion          u tcversion 

which means tcversion not there.

actually tcversion inside main tc library

$ nm /home/siddharth/tools/tc/lib/libtokyocabinet.so | grep -i tcversion 0008096c d tcversion 

now, question is, how can make these libraries connect?

better solution change makefile before running 'make' , 'make install'.

inside makefile replace libs by

libs = -lbz2 -lz -lpthread -lm -lc /home/siddharth/tools/tc/lib/libtokyocabinet.so.9 

add tc's lib dir in new tc.conf file under ld.so.conf.d

$ cat /etc/ld.so.conf.d/tc.conf  /home/siddharth/tools/tc/lib 

run ldconfig

sudo ldconfig -v 

build tc-java make includedir="/home/siddharth/tools/tc/include" libdir="/home/siddharth/tools/tc/lib"

check if linked properly

$ ldd libjtokyocabinet.so         linux-gate.so.1 =>  (0xb7fd7000)         libbz2.so.1.0 => /lib/libbz2.so.1.0 (0xb7fa0000)         libz.so.1 => /usr/lib/libz.so.1 (0xb7f8b000)         libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb7f72000)         libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb7f4d000)         libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7dfe000)         libtokyocabinet.so.9 => /home/siddharth/tools/tc/lib/libtokyocabinet.so.9 (0xb7d82000)         /lib/ld-linux.so.2 (0xb7fd8000)         librt.so.1 => /lib/tls/i686/cmov/librt.so.1 (0xb7d79000) 

run tc's checks

make check 

now install library

make install 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -