Skip to content

unresolved external symbol _DllMain #96423

Closed
@ghost

Description

Code

I tried this code:

[lib]
crate_type = ["cdylib"]
#[no_mangle]
extern "system" fn DllMain(module: HINSTANCE, reason: u32, _reserved: *mut c_void) -> i32 {
    if reason == DLL_PROCESS_ATTACH {
        unsafe {
            DisableThreadLibraryCalls(module);
        }

        thread::spawn(move || unsafe { dll_attach() });

        return 1;
    }

    return 0;
}
error: linking with `link.exe` failed: exit code: 1120
symbols.o : error LNK2001: unresolved external symbol _DllMain
  Hint on symbols that are defined and could potentially match:
    _DllMain@12
C:\Users\random\Desktop\project\target\i686-pc-windows-msvc\debug\deps\test.dll : fatal error LNK1120: 1 unresolved externals

It seems like #[no_mangle] is not working anymore.

Version it worked on

rustc --version --verbose:

rustc 1.62.0-nightly (18f314e70 2022-04-24)
binary: rustc
commit-hash: 18f314e7027fe7084aaab8620c624a0d7bd29e70
commit-date: 2022-04-24
host: x86_64-pc-windows-msvc
release: 1.62.0-nightly
LLVM version: 14.0.1

Version with regression

rustc --version --verbose:

rustc 1.62.0-nightly (055bf4ccd 2022-04-25)
binary: rustc
commit-hash: 055bf4ccd521c2c2185166c86951be7be145727c
commit-date: 2022-04-25
host: x86_64-pc-windows-msvc
release: 1.62.0-nightly
LLVM version: 14.0.1

Metadata

Metadata

Assignees

Labels

A-linkageArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.O-windows-msvcToolchain: MSVC, Operating system: WindowsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-untriagedUntriaged performance or correctness regression.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions