Skip to content

Error 126 while loadind DLL compiled by Rust on Windows #33842

Closed
@dancing-in-the-air

Description

Loading DLL compiled by Rust 1.8.0 on Windows 10 x64 results in error 126.

lib.rs as simple as follow:

use std::fs::File;
use std::io::Write;

#[no_mangle]
pub extern fn test_dll_call() -> u8 {
    let mut f = File::create("C:\\test.txt").unwrap();
    f.write(b"Hello, world!").unwrap();
    return 0
}

Cargo.toml

[package]
name = "test"
version = "0.1.0"
authors = ["user"]

[lib]
name = "test"
crate-type = ["dylib"]

[dependencies]


[profile.release]
opt-level = 3
debug = false
rpath = false
lto = false
debug-assertions = false
codegen-units = 1

It's built by simple cargo build --release

rustc --version --verbose

rustc 1.8.0 (db2939409 2016-04-11)
binary: rustc
commit-hash: db2939409db26ab4904372c82492cd3488e4c44e
commit-date: 2016-04-11
host: i686-pc-windows-msvc
release: 1.8.0

As a result DependencyWalker shows a lot of API-MS-W1IN-CORE-* DLLs missing in my system for the compiled DLL:
API-MS-WIN-CORE-APIQUERY-L1-1-0.DLL
API-MS-WIN-CORE-APPCOMPAT-L1-1-1.DLL
API-MS-WIN-CORE-APPINIT-L1-1-0.DLL
API-MS-WIN-CORE-ATOMS-L1-1-0.DLL
...

However on my Windows 10 x64 system I've already installed MS Visual Studio 2015 and MS C++ Redistributables 2005, 2010, 2012, 2013 and 2015.

I've picked up errors during the DLL loading by ProcessMonitor. I'm confused by missing 整瑳搮汬.DLL.

How can I help to solve this problem?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    O-windowsOperating system: Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions