开云体育

Re: Current state of DMX support on Apple Silicon Macs? #mac-m1 #powerline


 

TLDR: I’ve done a little more work on why JMRI’s USB HDI support, used by e.g. the Anyma DMX support, doesn’t work in native mode on Apple Silicon. We _do_ have a version of that code that should work natively, but it’s not working on my M1 Mac. Is this due to an improper setup on my part, or something broken in the .jar JMRI uses? I could use some help sorting that out from somebody who understands dynamic linking on the Mac in Java. Please contact me off list if you can help. Thanks!

Longer:

When the Apple Silicon version used by JMRI fails to load, we get this:

[java] 16:19:03,132 mri.jmrix.AbstractUsbConnectionConfig ERROR - UnsatisfiedLinkError - the serial library has not been installed properly [AWT-EventQueue-0]
[java] 16:19:03,132 mri.jmrix.AbstractUsbConnectionConfig ERROR - java.library.path=/Users/jake/Documents/Trains/JMRI/projects/JMRI:/Users/jake/Documents/Trains/JMRI/projects/JMRI/lib/macosx/aarch64:/Users/jake/Documents/Trains/JMRI/projects/JMRI/lib/macosx:/Users/jake/Documents/Trains/JMRI/projects/JMRI/lib [AWT-EventQueue-0]
[java] 16:19:03,132 mri.jmrix.AbstractUsbConnectionConfig ERROR - Exception is {} [AWT-EventQueue-0]
[java] java.lang.UnsatisfiedLinkError: /private/var/folders/b5/7f3mtqj55fd7pxzhnckz68nh0000gn/T/usb4java12025525072169804161.tmp/libusb4java.dylib: dlopen(/private/var/folders/b5/7f3mtqj55fd7pxzhnckz68nh0000gn/T/usb4java12025525072169804161.tmp/libusb4java.dylib, 0x0001): Library not loaded: /opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib
[java] Referenced from: <D242CF53-6770-32AD-BCF1-717B7A28DDA7> /private/var/folders/b5/7f3mtqj55fd7pxzhnckz68nh0000gn/T/usb4java12025525072169804161.tmp/libusb4java.dylib
[java] Reason: tried: '/opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib' (no such file), '/opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib' (no such file), '/usr/lib/libusb-1.0.0.dylib' (no such file, not in dyld cache)
[java] at jdk.internal.loader.NativeLibraries.load(Native Method) ~[?:?]
[java] at jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:388) ~[?:?]
[java] at jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:232) ~[?:?]
[java] at jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:174) ~[?:?]
[java] at java.lang.ClassLoader.loadLibrary(ClassLoader.java:2394) ~[?:?]
[java] at java.lang.Runtime.load0(Runtime.java:755) ~[?:?]
[java] at java.lang.System.load(System.java:1953) ~[?:?]
[java] at org.usb4java.Loader.load(Loader.java:323) ~[usb4java-1.3.0.jar:?]

The line about "the serial library has not been installed properly” is from a JMRI error handler, so I don’t think that really means much.

These lines seem to be the core of the problem:

[java] 16:19:03,132 mri.jmrix.AbstractUsbConnectionConfig ERROR - Exception is {} [AWT-EventQueue-0]
[java] java.lang.UnsatisfiedLinkError: /private/var/folders/b5/7f3mtqj55fd7pxzhnckz68nh0000gn/T/usb4java12025525072169804161.tmp/libusb4java.dylib: dlopen(/private/var/folders/b5/7f3mtqj55fd7pxzhnckz68nh0000gn/T/usb4java12025525072169804161.tmp/libusb4java.dylib, 0x0001): Library not loaded: /opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib
[java] Referenced from: <D242CF53-6770-32AD-BCF1-717B7A28DDA7> /private/var/folders/b5/7f3mtqj55fd7pxzhnckz68nh0000gn/T/usb4java12025525072169804161.tmp/libusb4java.dylib
[java] Reason: tried: '/opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib' (no such file), '/opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib' (no such file), '/usr/lib/libusb-1.0.0.dylib' (no such file, not in dyld cache)

I _think_ those mean that the jar-contained org/usb4java/darwin-aarch64/libusb4java.dylib library was found and loading started, but then the process failed when that in turn tried to access /opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib

But I don’t have a /opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib file, or anything close to that. There’s not even a /opt/homebrew/opt, let alone the rest of the path.

It seems that the org/usb4java/darwin-aarch64/libusb4java.dylib in the .jar file has that string baked in.

I do have a file by that name at a different path. Homebrew decided to install it at /usr/local/Cellar/libusb/1.0.27/lib/libusb-1.0.0.dylib

If I make a symbolic link from /opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib to the file I have, then the file gets found (yeah!), but we get a new error because that file has x86_64 architecture (??)

% file /opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib
/opt/homebrew/opt/libusb/lib/libusb-1.0.0.dylib: Mach-O 64-bit dynamically linked shared library x86_64

I _think_ when I copied my system from my previous Intel machine, all the Intel-format libraries were copied over and are still here. But I don’t know what to do about this.

Anybody have any ideas? If so, perhaps contact me off list. This is getting quite technical.

Thanks in advance!

Bob


On Mar 16, 2025, at 5:19?PM, Paul Anderson via groups.io <paul@...> wrote:

The problem of the missing darwin-aarch64 code in the libusb4java project is pretty simple. While the /dist/darwin/build script builds both darwin-x86-64 and darwin-aarch64, the /dist/bundle script omits the darwin-aarch64 platform, so it's not in the jar file.
Or somebody might take that open-source () and create one themselves.
I don't love the idea from a maintainability standpoint, but forking our own libusb4java project could resolve this.
Sorry there doesn’t seem to be a more explicit answer.
Sometimes, that's the norm for distributed software development. I get it. We just have to rattle the necessary cages or roll our own until these dependent projects get some love.

Bob Jacobsen
rgj1927@...

Join [email protected] to automatically receive all group messages.