-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Error 126 while loading DLL compiled by Rust (as a cdylib) on Windows #69207
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
Comments
Error 126 for reference is Are you certain that you build and run the program in the same exact way between older and newer Windows? The slightest difference can easily cause this. |
@retep998 I just found out that on my older Windows it only succeeds if I run the program with EDIT: apparently there is a difference between a freshly-compiled cdylib and my
vs
most notably, VCRUNTIME140.dll is not there in ecs_game.dll. |
Why are there so many If you have VC++ I recommend doing My current guess is that you're depending on some C library being provided by one of the crates you depend on, and it succeeds when you run it in a way such that it can be found and it fails otherwise. |
Thanks for the help you're giving. I'm a windows newbie, so I am quite disoriented when it comes to troubleshooting this kind of stuff there :S
I guess the most likely culprit here are the csfml libs, which are the only non-system ones. EDIT: running dumpbin on the newer install yields the exact same result. |
@silverweed Hi, I am having the same problem. How did you solve it? Thanks! |
@fzyzcjy Hello, I just copied the DLLs that my dynamically loaded lib depended on in the executable directory so it could find them when calling LoadLibrary. |
Uh oh!
There was an error while loading. Please reload this page.
Note: looks very similar to #33842, but I'm opening a new issue since that is closed and old.
Basically I'm having the same issue here. This is my project which has 3 crates: one static lib, one dynamic lib (cdylib) and an executable.
The dynamic lib (ecs_game) depends on the static lib (ecs_engine) and gets compiled into a single DLL. The executable (ecs_runner) then loads the DLL dynamically (I'm using the
libloading
crate for that).Here is what happens:
I also tried to create a small C program that uses
LoadLibraryA
directly to load the library and it gives the same exact error.Am I doing something wrong here?
(this is the C loader:)
Note that if I link the DLL at link-time, it works fine. It's just dynamic loading that gives problems.
The text was updated successfully, but these errors were encountered: