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

Error loading extension: res//DodgeTheCreeps.gdextension #208

Closed
mareksubocz opened this issue Mar 28, 2023 · 21 comments · Fixed by #215
Closed

Error loading extension: res//DodgeTheCreeps.gdextension #208

mareksubocz opened this issue Mar 28, 2023 · 21 comments · Fixed by #215

Comments

@mareksubocz
Copy link

I've tried to run DodgeTheCreeps demo on M1 Macbook Pro. The project built and the game started, but nothing happened after clicking the "START" button inside the game and following errors appeared:

Can't open dynamic library: /Users/mareksubocz/it/gdext/examples/dodge-the-creeps/godot/../../../target/debug/libdodge_the_creeps.dylib, error: dlopen(/Applications/Godot.app/Contents/MacOS/../Frameworks/libdodge_the_creeps.dylib, 0x0002): tried: '/Applications/Godot.app/Contents/MacOS/../Frameworks/libdodge_the_creeps.dylib' (no such file).
  core/extension/gdextension.cpp:400 - GDExtension dynamic library not found: /Users/mareksubocz/it/gdext/examples/dodge-the-creeps/godot/../../../target/debug/libdodge_the_creeps.dylib
  Failed loading resource: res://DodgeTheCreeps.gdextension. Make sure resources have been imported by opening the project in the editor at least once.
  Can't open dynamic library: /Users/mareksubocz/it/gdext/examples/dodge-the-creeps/godot/../../../target/debug/libdodge_the_creeps.dylib, error: dlopen(/Applications/Godot.app/Contents/MacOS/../Frameworks/libdodge_the_creeps.dylib, 0x0002): tried: '/Applications/Godot.app/Contents/MacOS/../Frameworks/libdodge_the_creeps.dylib' (no such file).
  core/extension/gdextension.cpp:400 - GDExtension dynamic library not found: /Users/mareksubocz/it/gdext/examples/dodge-the-creeps/godot/../../../target/debug/libdodge_the_creeps.dylib
  Failed loading resource: res://DodgeTheCreeps.gdextension. Make sure resources have been imported by opening the project in the editor at least once.

The steps I took to set the project up were:

brew install godot
git clone https://github.com/godot-rust/gdext && cd gdext
export GODOT4_BIN=/Applications/Godot.app/Contents/MacOS/Godot
export LLVM_PATH=/Library/Developer/CommandLineTools/usr/bin
cargo build # successfully
cd examples/dodge-the-creeps
cargo build # successfully
godot # to run the game

Is there something I overlooked?

@Bromeon
Copy link
Member

Bromeon commented Mar 28, 2023

Could you check the contents of the directory gdext/examples/dodge-the-creeps/godot/../../../target/debug?

Also, try specifically cargo build -p dodge-the-creeps (although that shouldn't be necessary).

@mareksubocz
Copy link
Author

image

Also, cargo build -p dodge-the-creeps didn't fix anything.

@Bromeon
Copy link
Member

Bromeon commented Mar 28, 2023

Is there only the dynamic library for godot_macros?
Why not for godot?

@mareksubocz
Copy link
Author

mareksubocz commented Mar 28, 2023

Sorry, I'm not sure what you mean

EDIT:
I showed all of the contents of the debug folder if that's what you mean. Not sure why there are no libraries for godot itself.

@lilizoey
Copy link
Member

try to cd into examples/dodge-the-creeps/rust before building

@Bromeon
Copy link
Member

Bromeon commented Mar 28, 2023

Can you do the following, and paste the full command line + output?
Navigate to the gdext directory, then:

rm -rf target
cargo update
cargo build
ls -la target/debug

@mareksubocz
Copy link
Author

try to cd into examples/dodge-the-creeps/rust before building

That didn't change anything.

Can you do the following, and paste the full command line + output? Navigate to the gdext directory, then:

rm -rf target
cargo update
cargo build
ls -la target/debug

➜ gdext git:(master) ✗ rm -rf target
➜ gdext git:(master) ✗ cargo update
Updating crates.io index
➜ gdext git:(master) ✗ cargo build
Compiling libc v0.2.140
Compiling proc-macro2 v1.0.54
Compiling quote v1.0.26
Compiling unicode-ident v1.0.8
Compiling nanoserde-derive v0.1.19
Compiling regex-syntax v0.6.29
Compiling glob v0.3.1
Compiling memchr v2.5.0
Compiling either v1.8.1
Compiling minimal-lexical v0.2.1
Compiling clang-sys v1.6.0
Compiling cfg-if v1.0.0
Compiling syn v1.0.109
Compiling heck v0.4.1
Compiling nanoserde v0.1.32
Compiling which v4.4.0
Compiling nom v7.1.3
Compiling libloading v0.7.4
Compiling bindgen v0.63.0
Compiling regex v1.7.3
Compiling godot-codegen v0.1.0 (/Users/mareksubocz/it/gdext/godot-codegen)
Compiling cexpr v0.6.0
Compiling rustc-hash v1.1.0
Compiling lazycell v1.3.0
Compiling shlex v1.1.0
Compiling lazy_static v1.4.0
Compiling bitflags v1.3.2
Compiling peeking_take_while v0.1.2
Compiling paste v1.0.12
Compiling venial v0.5.0
Compiling once_cell v1.17.1
Compiling getrandom v0.2.8
Compiling glam v0.22.0
Compiling rand_core v0.6.4
Compiling ppv-lite86 v0.2.17
Compiling rand_chacha v0.3.1
Compiling itest v0.1.0 (/Users/mareksubocz/it/gdext/itest/rust)
Compiling rand v0.8.5
Compiling godot-macros v0.1.0 (/Users/mareksubocz/it/gdext/godot-macros)
Compiling godot-core v0.1.0 (/Users/mareksubocz/it/gdext/godot-core)
Compiling godot-ffi v0.1.0 (/Users/mareksubocz/it/gdext/godot-ffi)
Compiling godot v0.1.0 (/Users/mareksubocz/it/gdext/godot)
Compiling dodge-the-creeps v0.1.0 (/Users/mareksubocz/it/gdext/examples/dodge-the-creeps/rust)
Finished dev [unoptimized + debuginfo] target(s) in 44.07s
➜ gdext git:(master) ✗ ls -la target/debug
total 3544
drwxr-xr-x 10 mareksubocz staff 320 Mar 28 14:35 .
drwxr-xr-x@ 6 mareksubocz staff 192 Mar 28 14:35 ..
-rw-r--r-- 1 mareksubocz staff 0 Mar 28 14:34 .cargo-lock
drwxr-xr-x 52 mareksubocz staff 1664 Mar 28 14:34 .fingerprint
drwxr-xr-x 21 mareksubocz staff 672 Mar 28 14:34 build
drwxr-xr-x 239 mareksubocz staff 7648 Mar 28 14:34 deps
drwxr-xr-x 2 mareksubocz staff 64 Mar 28 14:34 examples
drwxr-xr-x 7 mareksubocz staff 224 Mar 28 14:34 incremental
-rw-r--r-- 1 mareksubocz staff 408 Mar 28 14:35 libgodot_macros.d
-rwxr-xr-x 1 mareksubocz staff 1808051 Mar 28 14:34 libgodot_macros.dylib
image

@Bromeon
Copy link
Member

Bromeon commented Mar 28, 2023

Thanks! This is very strange, it clearly compiles both godot and dodge-the-creeps crates, yet doesn't generate the cdylib files for them. For some reason, it does for macros though....

Do you get more information about cargo build output if you clean again, and then use the -v (verbose) flag? Please only list the godot-* and dodge-the-creeps crates, otherwise it's too much output 😅

@mareksubocz
Copy link
Author

image

Compiling godot-macros v0.1.0 (/Users/mareksubocz/it/gdext/godot-macros)
Running rustc --crate-name godot_macros --edition=2021 godot-macros/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type proc-macro --emit=dep-info,link -C prefer-dynamic -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C metadata=45969ee3b5d32581 -C extra-filename=-45969ee3b5d32581 --out-dir /Users/mareksubocz/it/gdext/target/debug/deps -C incremental=/Users/mareksubocz/it/gdext/target/debug/incremental -L dependency=/Users/mareksubocz/it/gdext/target/debug/deps --extern proc_macro2=/Users/mareksubocz/it/gdext/target/debug/deps/libproc_macro2-ec7a94c44b825f70.rlib --extern quote=/Users/mareksubocz/it/gdext/target/debug/deps/libquote-e2d12cf1ee92377f.rlib --extern venial=/Users/mareksubocz/it/gdext/target/debug/deps/libvenial-a672150ec89edc86.rlib --extern proc_macro

Compiling godot-core v0.1.0 (/Users/mareksubocz/it/gdext/godot-core)
Running rustc --crate-name build_script_build --edition=2021 godot-core/build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 --cfg 'feature="codegen-fmt"' --cfg 'feature="codegen-full"' --cfg 'feature="default"' -C metadata=f39c3073ea76eb08 -C extra-filename=-f39c3073ea76eb08 --out-dir /Users/mareksubocz/it/gdext/target/debug/build/godot-core-f39c3073ea76eb08 -C incremental=/Users/mareksubocz/it/gdext/target/debug/incremental -L dependency=/Users/mareksubocz/it/gdext/target/debug/deps --extern godot_codegen=/Users/mareksubocz/it/gdext/target/debug/deps/libgodot_codegen-1842597e275d7f2b.rlib
Running /Users/mareksubocz/it/gdext/target/debug/build/godot-core-f39c3073ea76eb08/build-script-build

Compiling godot-ffi v0.1.0 (/Users/mareksubocz/it/gdext/godot-ffi)
Running rustc --crate-name build_script_build --edition=2021 godot-ffi/build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 --cfg 'feature="codegen-fmt"' -C metadata=01c37074376d1143 -C extra-filename=-01c37074376d1143 --out-dir /Users/mareksubocz/it/gdext/target/debug/build/godot-ffi-01c37074376d1143 -C incremental=/Users/mareksubocz/it/gdext/target/debug/incremental -L dependency=/Users/mareksubocz/it/gdext/target/debug/deps --extern bindgen=/Users/mareksubocz/it/gdext/target/debug/deps/libbindgen-7f5a80cf3e50fa20.rlib --extern godot_codegen=/Users/mareksubocz/it/gdext/target/debug/deps/libgodot_codegen-1842597e275d7f2b.rlib
Running /Users/mareksubocz/it/gdext/target/debug/build/godot-ffi-01c37074376d1143/build-script-build
Running rustc --crate-name godot_ffi --edition=2021 godot-ffi/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 --cfg 'feature="codegen-fmt"' -C metadata=67478647ed79e866 -C extra-filename=-67478647ed79e866 --out-dir /Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/deps --target aarch64-apple-darwin -C incremental=/Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/incremental -L dependency=/Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/deps -L dependency=/Users/mareksubocz/it/gdext/target/debug/deps --extern paste=/Users/mareksubocz/it/gdext/target/debug/deps/libpaste-b6ef4f94fd2c453a.dylib
Running rustc --crate-name godot_core --edition=2021 godot-core/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 --cfg 'feature="codegen-fmt"' --cfg 'feature="codegen-full"' --cfg 'feature="default"' -C metadata=bd3b1c83ac063d3c -C extra-filename=-bd3b1c83ac063d3c --out-dir /Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/deps --target aarch64-apple-darwin -C incremental=/Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/incremental -L dependency=/Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/deps -L dependency=/Users/mareksubocz/it/gdext/target/debug/deps --extern glam=/Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/deps/libglam-77f28499c61910ab.rmeta --extern godot_ffi=/Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/deps/libgodot_ffi-67478647ed79e866.rmeta --extern once_cell=/Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/deps/libonce_cell-62a7ab7d2d5e1e17.rmeta

Compiling godot v0.1.0 (/Users/mareksubocz/it/gdext/godot)
Running rustc --crate-name godot --edition=2021 godot/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 --cfg 'feature="codegen-full"' --cfg 'feature="default"' --cfg 'feature="formatted"' -C metadata=ef54764a70294ad6 -C extra-filename=-ef54764a70294ad6 --out-dir /Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/deps --target aarch64-apple-darwin -C incremental=/Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/incremental -L dependency=/Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/deps -L dependency=/Users/mareksubocz/it/gdext/target/debug/deps --extern godot_core=/Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/deps/libgodot_core-bd3b1c83ac063d3c.rmeta --extern godot_macros=/Users/mareksubocz/it/gdext/target/debug/deps/libgodot_macros-45969ee3b5d32581.dylib

Compiling dodge-the-creeps v0.1.0 (/Users/mareksubocz/it/gdext/examples/dodge-the-creeps/rust)
Running rustc --crate-name dodge_the_creeps --edition=2021 examples/dodge-the-creeps/rust/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type cdylib --emit=dep-info,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C metadata=1ae71296d085bc06 --out-dir /Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/deps --target aarch64-apple-darwin -C incremental=/Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/incremental -L dependency=/Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/deps -L dependency=/Users/mareksubocz/it/gdext/target/debug/deps --extern godot=/Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/deps/libgodot-ef54764a70294ad6.rlib --extern rand=/Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/deps/librand-8f912428da39b905.rlib
Running rustc --crate-name itest --edition=2021 itest/rust/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type cdylib --emit=dep-info,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 --cfg 'feature="default"' -C metadata=4f2131549ed7936a --out-dir /Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/deps --target aarch64-apple-darwin -C incremental=/Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/incremental -L dependency=/Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/deps -L dependency=/Users/mareksubocz/it/gdext/target/debug/deps --extern godot=/Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/deps/libgodot-ef54764a70294ad6.rlib
Finished dev [unoptimized + debuginfo] target(s) in 44.59s

That's it. Regardless if we will manage to resolve it, thank you for your amazing help :)

@Bromeon
Copy link
Member

Bromeon commented Mar 28, 2023

--out-dir /Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/deps
-C incremental=/Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/incremental
-L dependency=/Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/deps
-L dependency=/Users/mareksubocz/it/gdext/target/debug/deps
--extern godot=/Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/deps/libgodot-ef54764a70294ad6.rlib
--extern rand=/Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug/deps/librand-8f912428da39b905.rlib

Interesting... 🤔

Can you run a

ls -la /Users/mareksubocz/it/gdext/target/aarch64-apple-darwin

and

ls -la /Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug

?

@mareksubocz
Copy link
Author

mareksubocz commented Mar 28, 2023

image

➜ gdext git:(master) ✗ ls -la /Users/mareksubocz/it/gdext/target/aarch64-apple-darwin
total 8
drwxr-xr-x@ 4 mareksubocz staff 128 Mar 28 14:48 .
drwxr-xr-x@ 6 mareksubocz staff 192 Mar 28 14:49 ..
-rw-r--r-- 1 mareksubocz staff 177 Mar 28 14:48 CACHEDIR.TAG
drwxr-xr-x 20 mareksubocz staff 640 Mar 28 14:49 debug

➜ gdext git:(master) ✗ ls -la /Users/mareksubocz/it/gdext/target/aarch64-apple-darwin/debug
total 530576
drwxr-xr-x 20 mareksubocz staff 640 Mar 28 14:49 .
drwxr-xr-x@ 4 mareksubocz staff 128 Mar 28 14:48 ..
-rw-r--r-- 1 mareksubocz staff 0 Mar 28 14:48 .cargo-lock
drwxr-xr-x 32 mareksubocz staff 1024 Mar 28 14:48 .fingerprint
drwxr-xr-x 8 mareksubocz staff 256 Mar 28 14:48 build
drwxr-xr-x 372 mareksubocz staff 11904 Mar 28 14:49 deps
drwxr-xr-x 2 mareksubocz staff 64 Mar 28 14:48 examples
drwxr-xr-x 8 mareksubocz staff 256 Mar 28 14:49 incremental
-rw-r--r-- 1 mareksubocz staff 75239 Mar 28 14:49 libdodge_the_creeps.d
-rwxr-xr-x 1 mareksubocz staff 2349798 Mar 28 14:49 libdodge_the_creeps.dylib
-rw-r--r-- 1 mareksubocz staff 74867 Mar 28 14:49 libgodot.d
-rw-r--r-- 1 mareksubocz staff 21952 Mar 28 14:49 libgodot.rlib
-rw-r--r-- 1 mareksubocz staff 750 Mar 28 14:49 libgodot_codegen.d
-rw-r--r-- 1 mareksubocz staff 1179648 Mar 28 14:48 libgodot_codegen.rlib
-rw-r--r-- 1 mareksubocz staff 74483 Mar 28 14:49 libgodot_core.d
-rw-r--r-- 1 mareksubocz staff 257589648 Mar 28 14:49 libgodot_core.rlib
-rw-r--r-- 1 mareksubocz staff 3798 Mar 28 14:49 libgodot_ffi.d
-rw-r--r-- 1 mareksubocz staff 2979128 Mar 28 14:48 libgodot_ffi.rlib
-rw-r--r-- 1 mareksubocz staff 76585 Mar 28 14:49 libitest.d
-rwxr-xr-x 1 mareksubocz staff 7204363 Mar 28 14:49 libitest.dylib

@Bromeon
Copy link
Member

Bromeon commented Mar 28, 2023

Ah, there they are!

In your .gdextension file inside examples/dodge-the-creeps/godot, it looks like you need two extra lines:

macos.debug.aarch64 = "res://../../../target/aarch64-apple-darwin/debug/libdodge_the_creeps.dylib"
macos.release.aarch64 = "res://../../../target/aarch64-apple-darwin/release/libdodge_the_creeps.dylib"

(maybe remove the existing macos entries for now).

I'm actually 100% unsure about "aarch64" part. Might also be "arm64" or something else. Could you try a few things?

It would likely work without any prefix (just macos.debug = "..."), however that means that macOS on other architecture may break.

@mareksubocz
Copy link
Author

mareksubocz commented Mar 28, 2023

Nice! That got rid of the problem, thank you so much!

I suspect however there is another thing to solve, the sprites don't display properly:
image

EDIT:
FYI, the setting that works is macos.debug.arm64 and macos.release.arm64

@Bromeon
Copy link
Member

Bromeon commented Mar 28, 2023

Nice! That got rid of the problem, thank you so much!

Which architecture was it? How does your .gdextension file look now?

Btw, you should also be able to get the name through Engine::get_architecture_name.

I suspect however there is another thing to solve, the sprites don't display properly:

Can you open the editor once, save all scenes and see if anything changes?
From the command line, you can navigate to the dodge-the-creeps/godot directory and run godot4 -e.

@mareksubocz
Copy link
Author

architecture is arm64.

DodgeTheCreeps.gdextension:

[configuration]
entry_symbol = "gdext_rust_init"

[libraries]
linux.debug.x86_64 = "res://../../../target/debug/libdodge_the_creeps.so"
linux.release.x86_64 = "res://../../../target/release/libdodge_the_creeps.so"
macos.debug = "res://../../../target/debug/libdodge_the_creeps.dylib"
macos.release = "res://../../../target/release/libdodge_the_creeps.dylib"
windows.debug.x86_64 = "res://../../../target/debug/dodge_the_creeps.dll"
windows.release.x86_64 = "res://../../../target/release/dodge_the_creeps.dll"
macos.debug.arm64 = "res://../../../target/aarch64-apple-darwin/debug/libdodge_the_creeps.dylib"
macos.release.arm64 = "res://../../../target/aarch64-apple-darwin/release/libdodge_the_creeps.dylib"

saving the scenes triggers the same warnings. Do you want me to paste the outputs of godot4 -e? It doesn't fix the warnings.

@mareksubocz
Copy link
Author

Let me know if you need it as text, as there is quite a lot of it :)

image

image

image

image

@Bromeon
Copy link
Member

Bromeon commented Mar 28, 2023

Also changing the scenes slightly (in insignificant ways) + saving doesn't update the files? You should see changes in git diff for Mob.tscn and Player.tscn...

@mareksubocz
Copy link
Author

It does update the files, but the warnings stil remain. I'm not sure if Player.tsch is updated, as it is not present in git diff.

image

@Bromeon
Copy link
Member

Bromeon commented Mar 28, 2023

From your commit hashes:

index 32c2394..1775a2f

What are those? Looks like none of the recent gdext commits has them.

Does it also happen with latest master (commit 08c6594)?

@mareksubocz
Copy link
Author

I am currently using the latest commit. I don't know what those hashes mean, but i reverted all changes and compiled everything again and, despite still seeing some warnings, everything worked and I was able to play the game! Thank you so much :D Love the support of this project! The issue is ready to close.

@Bromeon
Copy link
Member

Bromeon commented Mar 28, 2023

Happy to hear it worked 🙂
Also, if you encounter more questions in the future, feel free to join or Discord, can sometimes be a bit faster 😎

If you don't mind, I will keep this issue open until I added support for aarch64 architecture on macOS.
Thanks a lot for reporting!

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

Successfully merging a pull request may close this issue.

3 participants