gdext icon indicating copy to clipboard operation
gdext copied to clipboard

FYI [wasm] the name of your rust library MUST be different than the godot project name

Open 0x53A opened this issue 1 year ago • 2 comments

I tried to get wasm export to work but would always get the error

Can't resolve symbol gdext_rust_init. Error: Tried to lookup unknown symbol "gdext_rust_init" in dynamic lib: game.wasm

That is, until I stumbled upon someone having the same issue and posting the solution: https://discord.com/channels/723850269347283004/1288906885746917447

Turns out, godot itself exports a file named <projectname>.wasm, so if you have named your rust library the same as your godot project, they will overwrite each other!

0x53A avatar Oct 29 '24 00:10 0x53A

We should add this to the book page, maybe among other similar things to keep in mind 🤔

Also, we can probably validate that they're not equal:

  • application/config/name is the ProjectSettings key for the project name
  • from Cargo env, we can get the library name

Bromeon avatar Oct 29 '24 08:10 Bromeon

I think this can either be part of the existing web PR (https://github.com/godot-rust/book/pull/56) or I can create a new PR after that one is merged, I'd just rather not mess around with the same article and cause merge conflicts

0x53A avatar Oct 29 '24 11:10 0x53A

We added a different validation regarding naming in https://github.com/godot-rust/gdext/pull/799, might be possible to extend that to also cover the project name. The Godot project name can be obtained via ProjectSetting.get_setting("application/config/name").

@PgBiel do you think that makes sense?

Bromeon avatar May 11 '25 15:05 Bromeon

This validation can't be done at runtime if I understood correctly, since the problem here is that our binary is overwritten and so never runs. It would have to be done within the editor, before exporting, in principle.

If we can do that, then it might make sense.

PgBiel avatar May 11 '25 15:05 PgBiel

Regarding docs, even though we already mention this problem in "Troubleshooting", we could consider adding that particular error to "Understanding common errors" as well.

PgBiel avatar May 11 '25 15:05 PgBiel

I assume most people test natively and then export for web, so the verification could be done in the windows/macos/linux build(s).

0x53A avatar May 11 '25 18:05 0x53A