godotengine / godot-docs

Godot Engine official documentation
https://docs.godotengine.org
Other
3.88k stars 3.17k forks source link

Godot 4+(master) GDExtension C++ example instructions on macos not working #7246

Open jpedrick opened 1 year ago

jpedrick commented 1 year ago

Your Godot version:

% git rev-parse HEAD
2ff3cf9bf91dc532b0f435079aaf2ae6eee8609f

Issue description:

On MacOS gdexample.gdextension doesn't point to correct library:

ERROR: Can't open dynamic library: /Users/jpedrick/Development/godot-master-cpp-tutorial/cpp-tutorial/demo/bin/libgdexample.macos.framework, error: dlopen(/Users/jpedrick/Development/godot.git/bin/../Frameworks/libgdexample.macos.framework, 0x0002): tried: '/Users/jpedrick/Development/godot.git/bin/../Frameworks/libgdexample.macos.framework' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/jpedrick/Development/godot.git/bin/../Frameworks/libgdexample.macos.framework' (no such file), '/Users/jpedrick/Development/godot.git/bin/../Frameworks/libgdexample.macos.framework' (no such file).
   at: open_dynamic_library (platform/macos/os_macos.mm:191)
ERROR: GDExtension dynamic library not found: /Users/jpedrick/Development/godot-master-cpp-tutorial/cpp-tutorial/demo/bin/libgdexample.macos.framework
   at: open_library (core/extension/gdextension.cpp:400)
ERROR: Failed loading resource: res://bin/gdexample.gdextension. Make sure resources have been imported by opening the project in the editor at least once.
   at: _load (core/io/resource_loader.cpp:223)

Two fixes are needed:

1) scons platform=macos => scons platform=macos target=editor 2) gdexample.gdextension =>

[configuration]

entry_symbol = "example_library_init"

[libraries]

linux.64="res://bin/libgdexample.linux.64.so"
windows.x86_64="res://bin/libgdexample.windows.x86_64.dll"
macos="res://bin/libgdexample.macos.editor.framework/libgdexample.macos.editor"

URL to the documentation page:

https://docs.godotengine.org/en/stable/tutorials/scripting/gdextension/gdextension_cpp_example.html

paddy-exe commented 1 year ago

Which godot-cpp commit do you use? Also, does this only occur for editor builds or also for debug builds? My tests for the docs were mainly built on the debug build which only entailed the .framework/ folder for MacOS and worked with only this part

jpedrick commented 1 year ago

Hi @paddy-exe , I used the 4.0 release as well as:

commit feaba551b5a5b2d13ad1c3fdd8c90e67c67ff37c

The key problem is that shared library is in a directory.