jpnurmi / libserialport.dart

Serial Port for Dart
https://pub.dev/packages/libserialport
GNU Lesser General Public License v3.0
86 stars 34 forks source link

Dynamic library linking in Dart only applications on Mac M1 #21

Open gerardsimons opened 3 years ago

gerardsimons commented 3 years ago

Hey there,

I am writing a CLI companion app for my Flutter apps that should not rely on Flutter so I want to get it working without using flutter_serial_port. I managed to compile and run the C examples of libserialport but I am getting an issue running the example here that should do the same thing (list the ports).

First of all I had to mess around with DYLD_LIBRARY_PATH and set it to my installation of libserialport (not sure if that's the proper way to figure out the library linking stuff in the case of Dart), but then I get this exception:

Invalid argument(s): Failed to load dynamic library (dlopen(libserialport.dylib, 1): no suitable image found.  Did find:
    /opt/homebrew/Cellar/libserialport/0.1.1/lib/libserialport.dylib: mach-o, but wrong architecture

This is why I mentioned Mac M1 in the title as I thought maybe it had something to do with the ARM instruction set? Then again I think Mach-O is what the architecture was before this so I am not sure. Any help would be greatly appreciated!

gerardsimons commented 3 years ago

This seems to be an issue with Dart and ffi itself, I have commented on this issue here: https://github.com/dart-lang/sdk/issues/39231. Feel free to close it

bretmh commented 3 years ago

Same issue here not an M1 mac.

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 2.0.2, on macOS 11.2.3 20D91 darwin-x64, locale en-US) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1) [✓] Xcode - develop for iOS and macOS [✓] Chrome - develop for the web [✓] Android Studio (version 4.0) [✓] VS Code (version 1.54.3) [✓] Connected device (2 available)

• No issues found!