Fazecast / jSerialComm

Platform-independent serial port access for Java
GNU Lesser General Public License v3.0
1.34k stars 287 forks source link

Native error when running on Raspberry Pi #277

Closed steveohara closed 4 years ago

steveohara commented 4 years ago

Hi Will, I'm getting the following error when I try and run v2.6.0 (v2.5.3 works fine) on a raspi;

Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/jSerialComm/1585401751988-libjSerialComm.so: /lib/arm-linux-gnueabihf/libc.so.6: version `GLIBC_2.28' not found (required by /tmp/jSerialComm/1585401751988-libjSerialComm.so)
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
        at java.lang.Runtime.load0(Runtime.java:809)
        at java.lang.System.load(System.java:1086)
        at com.fazecast.jSerialComm.SerialPort.<clinit>(SerialPort.java:248)
        at com.ghgande.j2mod.modbus.net.SerialConnection.open(SerialConnection.java:92)
        at com.ghgande.j2mod.modbus.facade.ModbusSerialMaster.connect(ModbusSerialMaster.java:94)
        at com.ghgande.j2mod.modbus.util.ModPoll.execute(ModPoll.java:119)
        at com.ghgande.j2mod.modbus.util.ModPoll.mainSerial(ModPoll.java:78)
        at com.ghgande.j2mod.modbus.util.ModPoll.main(ModPoll.java:41)

Raspbian version;

Description:    Raspbian GNU/Linux 9.4 (stretch)
Release:        9.4
Codename:       stretch
Linux SMARTstation 4.14.79-v7+ #1159 SMP Sun Nov 4 17:50:20 GMT 2018 armv7l GNU/Linux
hedgecrw commented 4 years ago

Based on a different issue, it looks like GLIBC introduced some breaking compatibility changes with v2.28 so I'm having to revert to v2.27 to ensure native library compatibility on some systems. Can you test the following version and see if this works for you. If you not, we will have to investigate further:

https://www.dropbox.com/s/qiotswg6os3bv61/jSerialComm-2.6.1.jar?dl=0

steveohara commented 4 years ago

Hi Will,

That link doesn’t work unfortunately. I’m happy to take a snapshot off maven central if you want to publish a dev build there.

Thanks, Steve

From: Will Hedgecock notifications@github.com Sent: 01 April 2020 22:53 To: Fazecast/jSerialComm jSerialComm@noreply.github.com Cc: Steve O'Hara sohara@pivotal-solutions.co.uk; Author author@noreply.github.com Subject: Re: [Fazecast/jSerialComm] Native error when running on Raspberry Pi (#277)

Based on a different issue, it looks like GLIBC introduced some breaking compatibility changes with v2.28 so I'm having to revert to v2.27 to ensure native library compatibility on some systems. Can you test the following version and see if this works for you. If you not, we will have to investigate further:

https://www.dropbox.com/s/qiotswg6os3bv61/jSerialComm-2.6.1.jar?dl=0

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/Fazecast/jSerialComm/issues/277#issuecomment-607508561, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAHOYK5YIZ2Q4F25CME4GPLRKOZVPANCNFSM4LVSLR5Q.

hedgecrw commented 4 years ago

Hey Steve,

Sorry, I updated the library again and forgot to update the link. Please try this one:

https://www.dropbox.com/s/96b082qk9nqigxa/jSerialComm-2.6.1.jar?dl=0

steveohara commented 4 years ago

Cheers Will, that version works a treat! Thanks Steve

fenugrec commented 2 years ago

Hi, I'm also getting this error with some software that includes jSerialcomm. Machine is runing Arch linux on x86-64; glibc 2.33

Exception in thread "Scan ports" java.lang.UnsatisfiedLinkError: /tmp/jSerialComm/1640129291912-libjSerialComm.so: /tmp/jSerialComm/1640129291912-libjSerialComm.so: failed to map segment from shared object
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1934)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1817)
    at java.lang.Runtime.load0(Runtime.java:810)
    at java.lang.System.load(System.java:1088)
    at com.fazecast.jSerialComm.SerialPort.<clinit>(SerialPort.java:243)
    at dk.hkj.comm.SerialInterface.getSerialPorts(SerialInterface.java:271)
    at dk.hkj.main.InterfaceThreads$ScanPorts.run(InterfaceThreads.java:736)

That software (https://lygte-info.dk/pic/Projects/TestController/) is distributed as a .jar file; I tried a manual method of repacking the .jar and replacing the jSerialComm parts with a few different versions (2.5.3, 2.6.1, 2.6.2, latest 2.7.0) and I'm always getting the same exception. Maybe my process of repacking the .jar is flawed but it would probably not even work, whereas now I'm always getting the same error.

hedgecrw commented 2 years ago

Please retry using today's library release v2.8.0.

fenugrec commented 2 years ago

Please retry using today's library release v2.8.0.

Thanks @hedgecrw . Not much better, but at least a different error message:

Starting
OpenJDK 64-Bit Server VM warning: You have loaded library /tmp/jSerialComm/1641691463497-backup-libjSerialComm.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
Exception in thread "Scan ports" java.lang.UnsatisfiedLinkError: Cannot load native libraries /tmp/jSerialComm/1641691463497-libjSerialComm.so or /tmp/jSerialComm/1641691463497-backup-libjSerialComm.so with expected architectures: Linux/x86_64 or Linux/x86
    at com.fazecast.jSerialComm.SerialPort.<clinit>(SerialPort.java:334)
    at dk.hkj.comm.SerialInterface.getSerialPorts(SerialInterface.java:276)
    at dk.hkj.main.InterfaceThreads$ScanPorts.run(InterfaceThreads.java:736)
fenugrec commented 2 years ago

I opened #387 instead of continuing to hijack this ticket. TLDR : mostly solved, at least as far as I'm concerned!