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

Win10: Trying to link Bevy dynamically results in the error STATUS_ENTRYPOINT_NOT_FOUND #1126

Open
TheZalli opened this issue Dec 21, 2020 · 11 comments
Labels
C-Startup A crash that occurs when first attempting to run a Bevy app O-Windows Specific to the Windows desktop operating system

Comments

@TheZalli
Copy link

Bevy version

0.4

Operating system & version

Windows 10, version: 1909, OS build: 18363.1256, 64-bit

What you did

I ran the binary with cargo run --features bevy/dynamic as instructed by the Bevy book. I believe I had the correct software and the given config.toml file at the folder .cargo

What you expected to happen

The game running regularly and opening my screen, just like when not using the features flag.

What actually happened

After the cargo started running the application, it exited with the error message:
error: process didn't exit successfully: `target\debug\<crate>.exe` (exit code: 0xc0000139, STATUS_ENTRYPOINT_NOT_FOUND)

Additional information

The current code is basically a very slightly modified version of the 3d scene example from the repo, with only main.rs in the src folder and no other dependencies besides Bevy 0.4.

I tried removing the "-Zshare-generics=y" flag from .cargo/config.toml, and also running it with stable. Both variations had the same result and message.

When I had only the cargo's autogenerated helloworld in my main.rs, the binary functioned normally with and without the flag, which is why I believe that my setup should be correct.

@memoryruins memoryruins added A-Build-System Related to build systems or continuous integration O-Windows Specific to the Windows desktop operating system labels Dec 22, 2020
@cart
Copy link
Member

cart commented Dec 23, 2020

Hmm yeah a number of people are reporting issues with dynamic linking on windows. Currently I'm working from my linux/mac laptop, so I won't be able to investigate Windows-related issues until I get back to my desktop in early-January. I'm hoping a motivated Windows user will pick this up before then 😄

@goooosick
Copy link

Building without fast-build configuration gives link error 1189 (too many objects). It compiles with fast-build, but the generated DLL has exact 65536 functions exported. It seems the DLL being sliently truncated.

@cart
Copy link
Member

cart commented Dec 23, 2020

I have a feeling that glsl-to-spirv is the culprit. Basically every link issue we've had in the past can be traced back to it. Maybe try removing that dep and commenting out relevant code until it compiles? It wouldn't work but if we don't get the link error, then we have our culprit.

@Cupnfish
Copy link
Contributor

I’ve encountered all of these problems and found a solution, and I think we should create a README file for anyone who has a problem to solve.
STATUS_ENTRYPOINT_NOT_FOUND:
1.Create a cargo profile under your game project, such as this:

├── .cargo  
│   └── config.toml
├── .gitignore
├── Cargo.lock
├── Cargo.toml
└── src
    └── main.rs

2.Modify the config.toml file as:

[target.x86_64-pc-windows-msvc]
linker = "rust-lld.exe"
rustflags = ["-Zshare-generics=off"]   # Here is the key to solving this problem

3.(optional) next modify your Cargo.toml makes it easy for you to run your project directly:

[dependencies]
bevy = { version = "0.4", features = ["dynamic"] }

4.Run your project happily:

cargo run

If you did not choose 3:

cargo run --features bevy/dynamic

This method also applies to #1110

I need your feedback.

@goooosick
Copy link

goooosick commented Dec 23, 2020

@Cupnfish I think you're right. There are over 90k monomorphized functions from rust core in .so file built on linux. Disabling share-generics makes total exported functions down to 19k on windows.

@Keithcat1
Copy link

For me, using link.exe instead of rust-lld.exe on Windows fixed the problem.
But I can only compile in release mode or I get that error message: bevy_dylib.dll has more than 65535 objects.

@TheZalli
Copy link
Author

TheZalli commented Jan 4, 2021

@Cupnfish
Doing that seems to have worked for me, thank you.

@alice-i-cecile
Copy link
Member

alice-i-cecile commented Sep 27, 2021

I can verify that @cupnfish's solution is working for me on Windows :)

@alice-i-cecile alice-i-cecile added C-Startup A crash that occurs when first attempting to run a Bevy app and removed A-Build-System Related to build systems or continuous integration labels Mar 21, 2022
greyna added a commit to greyna/bevy-website that referenced this issue Apr 24, 2022
Looks like on Windows dynamic linking works but only when deactivating Generic sharing (bevyengine/bevy#1126). This commit corrects the text.
@Divakar-2508
Copy link

@Cupnfish
did the exact same and the output i got,
error: failed to run rustc to learn about target-specific information

Caused by:
process didn't exit successfully: rustc - --crate-name ___ --print=file-names -Zshare-generics=off --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=crate-name --print=cfg (exit code: 1)
--- stderr
error: the option Z is only accepted on the nightly compiler

@alice-i-cecile
Copy link
Member

@Divakar-2508: In order to enable dynamic linking, you need to install and use nightly Rust.

@Divakar-2508
Copy link

@alice-i-cecile aight, I'll check it and update! :)

github-merge-queue bot pushed a commit that referenced this issue Jul 2, 2024
# Objective

- #13136 changed the default
value of `-Zshare-generics=n` to `-Zshare-generics=y` on Windows
- New users are encouraged to use dynamic builds and LLD when setting up
Bevy
- New users are also encouraged to check out `fast_config.toml`
- #1126 means that running
dynamic builds, using LLD and sharing generics on Windows results in a
cryptic error message

As a result, a new Windows user following all recommendations for better
compiles is actually not able to compile Bevy at all.

## Solution

- Set `-Zshare-generics=n` on Windows with a comment saying this is for
dynamic linking

## Testing

I verified that #1126 is still
in place on the current nightly (1.80)

## Additional Info

Maybe the website should mention this as well? The relevant snippet
there looks like this:
```toml
# /path/to/project/.cargo/config.toml
[target.x86_64-unknown-linux-gnu]
rustflags = [
  # (Nightly) Make the current crate share its generic instantiations
  "-Zshare-generics=y",
]
```
so it kinda implies it's only for Linux? Which is not quite true, this
setting works on macOS as well AFAIK
zmbush pushed a commit to zmbush/bevy that referenced this issue Jul 3, 2024
# Objective

- bevyengine#13136 changed the default
value of `-Zshare-generics=n` to `-Zshare-generics=y` on Windows
- New users are encouraged to use dynamic builds and LLD when setting up
Bevy
- New users are also encouraged to check out `fast_config.toml`
- bevyengine#1126 means that running
dynamic builds, using LLD and sharing generics on Windows results in a
cryptic error message

As a result, a new Windows user following all recommendations for better
compiles is actually not able to compile Bevy at all.

## Solution

- Set `-Zshare-generics=n` on Windows with a comment saying this is for
dynamic linking

## Testing

I verified that bevyengine#1126 is still
in place on the current nightly (1.80)

## Additional Info

Maybe the website should mention this as well? The relevant snippet
there looks like this:
```toml
# /path/to/project/.cargo/config.toml
[target.x86_64-unknown-linux-gnu]
rustflags = [
  # (Nightly) Make the current crate share its generic instantiations
  "-Zshare-generics=y",
]
```
so it kinda implies it's only for Linux? Which is not quite true, this
setting works on macOS as well AFAIK
MrGVSV pushed a commit to MrGVSV/bevy that referenced this issue Jul 5, 2024
# Objective

- bevyengine#13136 changed the default
value of `-Zshare-generics=n` to `-Zshare-generics=y` on Windows
- New users are encouraged to use dynamic builds and LLD when setting up
Bevy
- New users are also encouraged to check out `fast_config.toml`
- bevyengine#1126 means that running
dynamic builds, using LLD and sharing generics on Windows results in a
cryptic error message

As a result, a new Windows user following all recommendations for better
compiles is actually not able to compile Bevy at all.

## Solution

- Set `-Zshare-generics=n` on Windows with a comment saying this is for
dynamic linking

## Testing

I verified that bevyengine#1126 is still
in place on the current nightly (1.80)

## Additional Info

Maybe the website should mention this as well? The relevant snippet
there looks like this:
```toml
# /path/to/project/.cargo/config.toml
[target.x86_64-unknown-linux-gnu]
rustflags = [
  # (Nightly) Make the current crate share its generic instantiations
  "-Zshare-generics=y",
]
```
so it kinda implies it's only for Linux? Which is not quite true, this
setting works on macOS as well AFAIK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Startup A crash that occurs when first attempting to run a Bevy app O-Windows Specific to the Windows desktop operating system
Projects
None yet
Development

No branches or pull requests

8 participants