The `dynamic_linking` feature doesn't produce a Windows exe which can easily run outside Cargo
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## Bevy version
0.12.1
## \[Optional\] Relevant system information
Win11
## What you did
Try to run `program.exe` from either the `target/debug` or the `target/debug/deps` folder.
## What went wrong
Program fails to start:
- Missing `bevy_dylib-34dfd29b56be4d40.dll` if not in `deps/`.
- Missing `std-5a4aac4b2cd4ff41.dll` in both cases, and I have no idea where it is (nowhere under my project hierarchy, I assume somewhere in some Cargo cache?).
## Additional information
It's all too complicated and requires too much tribal knowledge to run a simple application outside of `cargo run`. One example is hooking RenderDoc, but otherwise just simply to run it without having to open a terminal.
- The application depends on a couple of DLLs in unknown locations.
- The application is present in at least 2 folders (see above).
- The application also has requirements on the working directory to find the `assets/` folder.
Trying to match all requirements at once is extremely difficult, because you're limited to a single working directory (which is the simplest way to fix most of those issues). I probably managed to do it in the past, but I already forgot how, if it didn't change in the meantime.
Additionally it looks like some `bevy_dylib.dll` was copied in `target/debug`, possibly as an attempt to fix that (?), however the executable produced depends on the version with the hash, not the stripped one, as `objdump` confirmed:
```txt
> objdump -x program.exe | findstr DLL
DLL Name: bevy_dylib-34dfd29b56be4d40.dll
DLL Name: std-5a4aac4b2cd4ff41.dll
DLL Name: SHLWAPI.dll
DLL Name: kernel32.dll
DLL Name: user32.dll
DLL Name: ole32.dll
DLL Name: oleaut32.dll
DLL Name: VCRUNTIME140.dll
DLL Name: api-ms-win-crt-math-l1-1-0.dll
DLL Name: api-ms-win-crt-runtime-l1-1-0.dll
DLL Name: api-ms-win-crt-stdio-l1-1-0.dll
DLL Name: api-ms-win-crt-locale-l1-1-0.dll
DLL Name: api-ms-win-crt-heap-l1-1-0.dll
```
I couldn't find any relevant (enough) information in documentations. On docs.rs, there's no mention of `dynamic_linking` anywhere. On the Bevy website, there's the following note:
> NOTE: Remember to revert this before releasing your game! Otherwise you will need to include libbevy_dylib alongside your game if you want it to run. If you remove the "dynamic" feature, your game executable can run standalone.
But it falls short of giving enough information for the user to actually fix the issue as 1) the location of the DLL is not explained, and 2) as shown above this is not enough, you also need `std-xxx.dll`.
Contributor guide
Assessment
This issue has not been assessed yet.