GDSerCommPlugin icon indicating copy to clipboard operation
GDSerCommPlugin copied to clipboard

Mac OS

Open dariocavada opened this issue 4 years ago • 12 comments

Is there a way to have this plugin working with Max OS ?

dariocavada avatar Dec 30 '20 14:12 dariocavada

Hi! I'm pretty sure there is. I don't own a Mac so I haven't been able to try compiling an binary.

My plan is to setup GitHub Actions with Mac OS and hopefully that's enough.

Feel free to give it a try compiling it on your Mac. Actually the Linux instructions may work

NangiDev avatar Jan 01 '21 11:01 NangiDev

I compiled libGDSercomm and libsercomm for Mac and edited the .gdnlib file like so:

[general]

singleton=false
load_once=true
symbol_prefix="godot_"
reloadable=false

[entry]

OSX.64="res://addons/GDSerCommDock/bin/libGDSercomm.dylib"
Windows.64="res://addons/GDSerCommDock/bin/GDSercomm.dll"
X11.64="res://addons/GDSerCommDock/bin/libGDSercomm.so"
X11.32="res://addons/GDSerCommDock/bin/libGDSercomm.so"

[dependencies]

OSX.64=[ "res://addons/GDSerCommDock/bin/libsercomm.dylib" ]
Windows.64=[  ]
X11.64=[  ]
X11.32=[  ]

I copied libGDSercomm.dylib and libsercomm.dylib into addons/GDSerCommDock/bin. When I open my project I get this error:

 Can't open dynamic library: /Users/w0028327/workdesk/godot-projects/addons/GDSerCommDock/bin/libGDSercomm.dylib, error: dlopen(/Users/w0028327/workdesk/godot-projects/addons/GDSerCommDock/bin/libGDSercomm.dylib, 2): Library not loaded: @rpath/libsercomm.dylib
  Referenced from: /Users/w0028327/workdesk/godot-projects/addons/GDSerCommDock/bin/libGDSercomm.dylib
  Reason: image not found.
 modules/gdnative/gdnative.cpp:501 - No valid library handle, can't get symbol from GDNative object
 modules/gdnative/nativescript/nativescript.cpp:1506 - No nativescript_init in "res://addons/GDSerCommDock/bin/libGDSercomm.dylib" found
 res://addons/GDSerCommDock/MenuLogic.gd:5 - Attempt to call function 'new' in base 'NativeScript' on a null instance

Any idea what's going on?

mrhubbs avatar Feb 26 '21 15:02 mrhubbs

I have seen this error before. I think it could be due to several issues, but I don't have a Mac so I can not test it myself.

What platform did you specify when build the GDSercomm library?

You might wanna use scons p=osx instead of scons p=platform

Please let me know if this works

NangiDev avatar Feb 27 '21 17:02 NangiDev

I have now updated the build instructions to what I think is correct. I think I will be manage to get my hands on an Apple computer soon so that I can try compiling and debug locally. Hopefully that leads to me being able to setup Github actions to automatically build the binaries for those that don't wanna compile it themselves

NangiDev avatar Mar 01 '21 14:03 NangiDev

I tried p=platform. I've also tried p=osx and I'm getting the same error. I know you'll test this but here are a couple of comments on your Mac instructions

git clone --depth=1 [email protected]:Superwaitsum/GDSercomm.git
cd GDSercomm/
git clone --depth=1 [email protected]:GodotNativeTools/godot_headers.git
git clone --depth=1 [email protected]:ingeniamc/sercomm.git
cd sercomm/
cmake -H. -Bbuild
cmake --build build
cd ..
cp sercomm/build/config.h sercomm/include/public/sercomm/
mkdir lib
# library extensions are .dylib not .so
cp sercomm/build/libsercomm.so lib/
scons p=osx
cp lib/libsercomm.so bin/
# it is not easy to get permissions to modify /usr/lib, even as a root user. I'm not sure it's necessary, either
cp bin/libsercomm.so /usr/lib
# no ldconfig on Mac, maybe: sudo update_dyld_shared_cache
ldconfig

mrhubbs avatar Mar 03 '21 16:03 mrhubbs

Thanks for trying. You are right. Good comments, I will update and also look into update_dyld_shared_cache

I'm hoping to get the Mac this weekend, but I'm starting to think it might be another problem. I will see if I get the same issues on Linux/windows

I would appreciate if you could keep debugging this on Mac.

If we could verify that the build steps are correct for all the platforms I will try setting up GitHub Actions for building all the binaries and then try to get everything up on Godot Marketplace. That would be golden 👍

NangiDev avatar Mar 04 '21 16:03 NangiDev

Sure, I'll be able to keep debugging. Let me know if there are any other things you'd like to try/test.

mrhubbs avatar Mar 04 '21 16:03 mrhubbs

I think I have found the problem. At least a potential problem. In the Scons build file the osx flags seems to be old. I think it builds the godot_native binaries wrong. Seems like build instructions are for older version of headers for osx.

Not sure, but it could definitely be a problem.

Not sure how to fix this. The dependent libraries are old and unmaintained. Ideally would be to redo everything and have them better maintained.

NangiDev avatar Mar 08 '21 09:03 NangiDev

Hmm, sounds tricky. What are the unmaintained, dependent libraries?

mrhubbs avatar Mar 09 '21 01:03 mrhubbs

Most of the parts in my repo is basically a fork from https://github.com/Superwaitsum/GDSercomm and that repo depends on https://github.com/GodotNativeTools/godot_headers and https://github.com/ingeniamc/sercomm

So in the Scons build file it build the godot_headers. It looks like, on first glance, that those headers seems to be built with wrong flags. I'm guessing it has old flags.

I have been looking into replacing these dependencies, except godot_headers of course, but I'm having problem finding more maintained and equivalent libraries. Also writing them from scratch is a bit over my skill, but I'm looking into it :)

NangiDev avatar Mar 09 '21 08:03 NangiDev

If you look here: https://github.com/Superwaitsum/GDSercomm/blob/master/SConstruct#L30

I think these flags refers to godot_headers flags att line 138 in https://github.com/godotengine/godot-headers/edit/master/README.md#L138

Am I correct?

NangiDev avatar Mar 09 '21 08:03 NangiDev

Yes I think you are correct. How does it work with the flags specified in the godo-headers readme?

mrhubbs avatar Mar 11 '21 21:03 mrhubbs

@mrhubbs Sorry for not getting back to you.

I am not sure about the flags. I actually don't have that much experience with serial connections and such. Also because I don't really have time I just try to hack stuff together trying to make it work for as many people as possible.

I really hope you found a solution to your problem. Maybe you can try the new 4.1+ version of the plugin, if you're still need serial communication.

I don't have any Apple hardware so I can't test it out for you.

NangiDev avatar Dec 10 '23 19:12 NangiDev

No problem. I was looking into this experimentally - it's not something I currently need. If I do, I'll try v 4.1+. Thanks!

mrhubbs avatar Feb 02 '24 15:02 mrhubbs