PCanBasic Java: unsatisfied link error

This forum covers PCAN-Linux and Linux development issues concerning our products
Post Reply
walkerjitzu
Posts: 6
Joined: Wed 5. Feb 2020, 15:31

PCanBasic Java: unsatisfied link error

Post by walkerjitzu » Thu 6. Feb 2020, 15:51

Hello, I would like to try out Peak PCanBasic Java but I'm having some problems with the library. I have installed the char driver and built and installed pcanbasic, and also pcanbasic_java it seems, but I get UnsatisfiedLinkError when calling initializeAPI() for PCANBasic. I don't understand what's wrong, as the libraries seem correctly built and loaded, also when running the application.
This is the result of make for pcanbasic_java:

Code: Select all

***
***
*** target=libpcanbasic_jni.so
*** version=1.9.0
***
*** gcc version=9
***
*** JAVA_HOME is '/usr/lib/jvm/default'
*** PCAN-Basic header found in '/usr/include'.

*** Compiling project:
gcc src/pcanbasic_jni.c -fPIC -shared -O2 -Wl,-soname,libpcanbasic_jni.so   -lc -lm -lpcanbasic -I. -I/usr/lib/jvm/default/include/ -I/usr/lib/jvm/default/include/linux -Wall -Wcast-align -Wcast-qual -Wimplicit  -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow -Wunused -o libpcanbasic_jni.so.1.9.0
Alessandro

F.Vergnaud
Software Development
Software Development
Posts: 305
Joined: Mon 9. Sep 2013, 12:21

Re: PCanBasic Java: unsatisfied link error

Post by F.Vergnaud » Fri 7. Feb 2020, 11:39

Hello Alessandro,

Here is a short recap on how to install PCAN-Basic Linux and PCAN-Basic Java JNI.
First be sure you have the PCAN Linux driver and PCAN-Basic Linux correctly installed:

Code: Select all

[peak@vbox-manjaro Developpement]$ wget https://www.peak-system.com/fileadmin/media/linux/files/peak-linux-driver-8.9.3.tar.gz
[peak@vbox-manjaro Developpement]$ tar xvzf peak-linux-driver-8.9.3.tar.gz 
[peak@vbox-manjaro Developpement]$ cd peak-linux-driver-8.9.3/
[peak@vbox-manjaro peak-linux-driver-8.9.3]$ make
[peak@vbox-manjaro peak-linux-driver-8.9.3]$ sudo make install
[peak@vbox-manjaro peak-linux-driver-8.9.3]$ pcaninfo
The final output command should show something similar to the following:
CAN driver version: 8.9.3

* pcanusbfd32: (/sys/class/pcan/pcanusbfd32)
- file: /dev/pcan32
- dev: "240:32"
- dev_name: "/dev/pcan32"
[...]
PCAN Linux driver does not inclute the Java package and its required JNI library. You have to download the standalone PCAN-Basic linux package and install libpcanbasic_jni:

Code: Select all

[peak@vbox-manjaro Developpement]$ wget http://www.peak-system.com/quick/BasicLinux -O pcanbasic_linux_4.3.2.tar.gz
[peak@vbox-manjaro Developpement]$ tar xvzf pcanbasic_linux_4.3.2.tar.gz
[peak@vbox-manjaro Developpement]$ cd PCAN-Basic_Linux-4.3.2/pcanbasic_java/libpcanbasic_jni/
[peak@vbox-manjaro libpcanbasic_jni]$ make
[peak@vbox-manjaro libpcanbasic_jni]$ sudo make install
Now let's build and run the PCANBasic Java Example:

Code: Select all

[peak@vbox-manjaro pcanbasic_java]$ cd ../examples/PCANBasicExample/src/
[peak@vbox-manjaro src]$ javac peak/can/basic/*.java
[peak@vbox-manjaro src]$ javac peak/can/*.java
[peak@vbox-manjaro src]$ java peak.can.Application 
The Java application runs, select a valid CAN channel and click the Connect button. The information box displays "PCAN_USBBUS1 Successfully unitialized".

If you have any error, do not hesite to copy/paste the output of all the upper commands. It will help to understand your issue.
Thanks
Best regards,
Fabrice

walkerjitzu
Posts: 6
Joined: Wed 5. Feb 2020, 15:31

Re: PCanBasic Java: unsatisfied link error

Post by walkerjitzu » Mon 17. Feb 2020, 14:00

Hi, thank you for your response. By running the PCan example application I was able to see that indeed the library that I built was created correctly, but for some reason if I try to run my application in the IDE I'm using (IntelliJ IDEA), it won't work as it throws UnsatisfiedLinkException. So I will try to work around that issue.

Thank you

Alessandro

Post Reply