kumikohime / gdpuredata

MIT License
5 stars 0 forks source link

Error on MacOS with M2 #2

Open MaxKablaam opened 1 month ago

MaxKablaam commented 1 month ago

I built the libpd and the gdextension following the instructions in the readme. Here is the error I'm getting in Godot Editor.

Godot Engine v4.3.stable.official (c) 2007-present Juan Linietsky, Ariel Manzur & Godot Contributors.
--- Debug adapter server started on port 6006 ---
--- GDScript language server started on port 6005 ---
  Can't open dynamic library: /Users/eric/Workspace/gdpuredata/addons/gdpuredata/bin/libgdpuredata.macos.template_debug.framework. Error: dlopen(/Users/eric/Workspace/gdpuredata/addons/gdpuredata/bin/libgdpuredata.macos.template_debug.framework/libgdpuredata.macos.template_debug, 0x0002): Library not loaded: libs/libpd.dylib
    Referenced from: <3E0B2905-BF1F-397F-90AE-122A17084DA3> /Users/eric/Workspace/gdpuredata/addons/gdpuredata/bin/libgdpuredata.macos.template_debug.framework/libgdpuredata.macos.template_debug
    Reason: tried: 'libs/libpd.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibs/libpd.dylib' (no such file), 'libs/libpd.dylib' (no such file).
  Can't open GDExtension dynamic library: /Users/eric/Workspace/gdpuredata/addons/gdpuredata/bin/libgdpuredata.macos.template_debug.framework
  Failed loading resource: res://addons/gdpuredata/gdpuredata.gdextension. Make sure resources have been imported by opening the project in the editor at least once.
  res://Test.gd:1 - Parse Error: Could not find base class "GDPureDataHandle".
  modules/gdscript/gdscript.cpp:2936 - Failed to load script "res://Test.gd" with error "Parse error". (User)
  Cannot get class 'GDPureDataHandle'.

I'm surprised that it is looking for libpd.dylib, which I may be mistaken, but that sounds like it's a dynamic library, when I followed the instructions to build a static library.

MaxKablaam commented 1 month ago

Ok, think I solved it. For some reason make STATIC=true still puts a libpd.dylib in the libs folder, and scons must pick that up along with the libpd.a, so it's looking for it when the editor starts. Deleting the libpd.dylib file seems to fix the issue. Any way to prevent the `libpd.dylib' from being created? Or to suppress it in SConstruct?

kumikohime commented 1 month ago

Hi! You can try explicitly referencing the .a file in the scons

https://github.com/kumikohime/gdpuredata/blob/672447d1e682a690ffa711c27279e6fee121e84a/gdextension/gdpuredata/SConstruct#L21-L27

Unfortunately I dont have a mac to test. 🙏 But you can try adding this line before L22 to overwrite the lib name when using mac. See if it works env.Replace(LIBS="libpd.a")

MaxKablaam commented 1 month ago

Thanks for looking into this. I just tested this and SCons is still picking up the .dylib 🤷‍♀️ I even tried setting the initial LIBS name and specifically ignoring the .dylib by changing the line at 17 to this:

env.Append(LIBS="libpd.a", LIBPATH=["libpd/libs/"])
env.Ignore(env.Dir('libpd/libs/'), 'libpd.dylib')

... and it still gives me that error in Godot, unless I manually delete the .dylib.