In wx.dll, there is a C language function defined as follows:
void __stdcall WXRelease(void *p);
I am trying to call it in Rust using stdcall:
run --package wxams --bin wxams --target=i686-pc-windows-msvc
, but I am encountering some issues:
#[link(name="wx", kind = "dylib")]
extern "stdcall" {
fn WXRelease(
ptr_to_release: *mut c_void
);
}
fn main() {
// let ptr = /*from other context*/
WXRelease(ptr);
}
When I try to run this program, I get the following compilation error:
Non-UTF-8 output: wxams.4kzsx1adypypail6.rcgu.o : error LNK2019: Missing external symbol __imp__WXRelease@4, which is referenced in function "hb72ac0487c2750d0".
If I change stdcall to C or cdecl, the compilation can proceed successfully. However, due to the calling convention mismatch, the program cannot run properly.
Is there any way to statically link this DLL instead of using dynamic calls to access the functions inside the DLL? In other words, is there a way to prevent name mangling from occurring with stdcall?
What I tried:
#[no_mangle], no effects.#[link_name="..."],@4will be appended to the end of link name.extern "system", worked likestdcall