Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDExtension library files won't load in a folder separate from the Godot executable #87761

Open
gamebox-project opened this issue Jan 30, 2024 · 3 comments · May be fixed by #88049
Open

GDExtension library files won't load in a folder separate from the Godot executable #87761

gamebox-project opened this issue Jan 30, 2024 · 3 comments · May be fixed by #88049

Comments

@gamebox-project
Copy link

gamebox-project commented Jan 30, 2024

Tested versions

4.2.1

System information

Linux

Issue description

My game's Godot executable and .pck file are in separate folders. By using --main-pack the .pck will be loaded just fine but not the GDExtension library present in the same folder as the .pck file. If there's an override.cfg in this separate folder, the override.cfg will load, though.

I've tried to set LD_LIBRARY_PATH and LD_PRELOAD to the folder where the .pck is. The GDExtension library file can't be loaded this way but the library file provided by the Steamworks SDK can.

Steps to reproduce

export LD_LIBRARY_PATH=/home/user/Desktop/pckandgde/

/home/user/Desktop/gameexec/game.x86_64 --main-pack /home/user/Desktop/pckandgde/pack.pck

ERROR: Can't open dynamic library: addons/godotsteam/linux64/libgodotsteam.x86_64.so. Error: /home/user/Desktop/gameexec/../lib/libgodotsteam.x86_64.so: cannot open shared object file: No such file or directory.
   at: open_dynamic_library (drivers/unix/os_unix.cpp:660)
ERROR: GDExtension dynamic library not found: addons/godotsteam/linux64/libgodotsteam.x86_64.so
   at: open_library (core/extension/gdextension.cpp:719)
ERROR: Failed loading resource: res://addons/godotsteam/godotsteam.gdextension. Make sure resources have been imported by opening the project in the editor at least once.
   at: _load (core/io/resource_loader.cpp:274)
ERROR: Error loading extension: res://addons/godotsteam/godotsteam.gdextension
   at: load_extensions (core/extension/gdextension_manager.cpp:234)

Minimal reproduction project (MRP)

N/A

@bruvzg
Copy link
Member

bruvzg commented Jan 31, 2024

GDExtension libraries are loaded only from a specific set of locations.

Try using /home/user/Desktop/gameexec/game.x86_64 --path /home/user/Desktop/pckandgde/ --main-pack pack.pck instead (it works on macOS, I have not tested on Linux).

@gamebox-project
Copy link
Author

According to Godot docs the --path must contain a project.godot file, however this is an exported project.

--path does work if I create that addons/etc/etc file structure, and add the GDExtension files there, but I would prefer if I didn't need any subfolders as that would make more sense for an exported project.

Also, the "../lib/" part is kind of weird in this scenario. I actually tried to move my GDExtension files to to a folder named "lib" on my desktop, and the files were able to load from there.

@bruvzg
Copy link
Member

bruvzg commented Feb 1, 2024

In case of Linux, it's looking at:

  • path as specified in the .gdextension file, it's res://addons/something so it's looking for the addons/something in the project path (which is set by --path).
  • executable location (only filename for the original path).
  • executable location + ../lib (only filename for the original path).

While we can add PCK location to the lookup list (and it will work on Linux and Windows), some systems (like macOS) are quite restrictive about dynamic library location, loading something for non-standard location will cause issues. So I'm not sure if we should change it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants