I am new to Ubuntu and searched on-line for two days, tried a lot of solutions but do not have any luck yet. If anyone can help with this, I will appreciate.
I wrote a program in Java with eclipse on Windows. My program makes use of Java hidapi library, which is a Java wrapper of the C version hidapi library (.dll). In eclipse, by adding the Java hidapi to the build path and setting the C hidapi as a native library, everything works just fine.
Now I want to do the same on Ubuntu. The same Java hidapi is used, which now will make use of the C version hidapi library for Linux (a .so file). When making the C version hidapi library for Linux, it turns out that I need another library called libusb-1.0 (which hidapi needs to deals with the low level communication). So I install libusb-1.0 (now I have a libusb-1.0.so file under /usr/lib/i386-linux-gnu), make the C version hidapi library for Linux. I have a small C program and I test it under bash, it works so I believe until this point everything, both libsub-1.0.so and C version hidapi library for Linux libhidapi-jni.so are installed/generated correctly, and when running the small C program the system is able to find the shared libusb-1.0.so library without explicitly mentioning where libsub-1.0 is (which makes sense because libusb-1.0 is installed in a place where the system loader will always search).
So I go to eclipse. I import the eclipse work space, add the Java hidapi to the build path (as I did in Windows), move the C version hidapi library for Linux (the .so file) into a folder called 'lib' (where the .dll version of native library also resides). And I set the native library to 'lib', by "build path" -> "configure build path" -> "libraries" tab -> "native library location". So till this point, the two native libraries are: libusb-1.0 under /usr/lib/i386-linux-gnu, and hidapi.so under 'wherever eclipse workspace is'/lib. Finally in the source code I add two lines:
System.loadLibrary("usb-1.0"); // Call this line A.
System.loadLibrary("hidapi-jni"); // Call this line B.
I run the program as a Java application. It reports "java.lang.UnsatisfiedLinkError: no usb-1.0 in java.library.path" at line A. So I guess the Java runtime is not able to find where libsub-1.0 is.
Just for clarification, I already did the following trials, none of them worked.
- Remain the two libraries where they are, add vm argument (Run -> Run Configuration -> Arguments -> VM arguments): -Djava.library.path="${workspace_loc:project_name}/lib; /usr/lib/i386-linux-gnu". It gives: "java.lang.UnsatisfiedLinkError: no usb-1.0 in java.library.path" at line A.
- Undo 1. Move libsub-1.0.so to 'wherever eclipse workspace is'/lib, so now the two .so files are together. Set .jar's native library location to this folder. It gives "java.lang.UnsatisfiedLinkError: blablabla: undefined symbol: libusb_control_transfer" at line B. So I think it founds the libusb library, however the symbol (which should be in libusb) is still unresolved. This is really weird.
Can anyone help me? Thanks in advance.