Fazecast / jSerialComm

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

Running JSerialComm on M1 Mac. 'java.lang.UnsatisfiedLinkError' #572

Open jimenezjose opened 2 months ago

jimenezjose commented 2 months ago

I already tried the following:

  1. Use the latest JSerialComm jar file
  2. Override the os.arch_full=armv8_64.

I am still running into issues.

It wasn't well documented, but the way I tried overriding the architecture was by using java -Dos.arch_full=armv8_64 -cp ...

Thank you in advance. I left the complete error at the bottom.

mkdir -p build
javac -Xlint:unchecked -cp lib/jSerialComm-2.11.0.jar:lib/commons-lang3-3.11.jar -g src/MazeGUI.java src/Mouse.java src/Maze.java src/MazeNode.java src/utility/Pair.java src/utility/PQNode.java src/utility/strings/ParsingStrings.java src/utility/comm/SerialRoute.java src/utility/comm/SerialRouteEvent.java  -d build
Exception in thread "main" java.lang.UnsatisfiedLinkError: /private/var/folders/9b/1k0116695fl2ql5xg_hqwrx800w1n9/T/1727145213540-libjSerialComm.jnilib: dlopen(/private/var/folders/9b/1k0116695fl2ql5xg_hqwrx800w1n9/T/1727145213540-libjSerialComm.jnilib, 0x0001): tried: '/private/var/folders/9b/1k0116695fl2ql5xg_hqwrx800w1n9/T/1727145213540-libjSerialComm.jnilib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/private/var/folders/9b/1k0116695fl2ql5xg_hqwrx800w1n9/T/1727145213540-libjSerialComm.jnilib' (no such file), '/private/var/folders/9b/1k0116695fl2ql5xg_hqwrx800w1n9/T/1727145213540-libjSerialComm.jnilib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))
    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:782)
    at java.lang.System.load(System.java:1100)
    at com.fazecast.jSerialComm.SerialPort.<clinit>(SerialPort.java:248)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at MazeGUI.main(MazeGUI.java:1098)
jimenezjose commented 2 months ago

Here is the Makefile, and the run script

jimenezjose commented 2 months ago

I also tried specifying a tmpdir -Djava.io.tmpdir=/Users/josejimenezjr/micromouse-simulator-temp

jskubick commented 2 months ago

FYI, I just ran into the same issue myself after building the current source from scratch, then attempting to call SerialPort.getCommPorts():

Exception in thread "main" java.lang.UnsatisfiedLinkError: Cannot load native library. Errors as follows:
[1]: no jSerialComm in java.library.path: /Users/jeff/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.

    at com.fazecast.jSerialComm.SerialPort.<clinit>(SerialPort.java:273)
    at com.fazecast.jSerialComm.HighThroughputNullmodemTest.main(HighThroughputNullmodemTest.java:64)

Execution failed for task ':com.fazecast.jSerialComm.HighThroughputNullmodemTest.main()'.

NOTE: In order to get it to compile, I had to change sourceCompatibility and targetCompatibility (in build.gradle) from 6 to 7. This might (or might not) be significant.