Search code examples
rustdllexport

Can't export stdcall method


I'm writing some code that use jni. My target platform is Windows. So my jni functions have to use stdcall calling convention but Rust exports functions only with cdecl calling convention.
I use MinGW(may be it important)

I wrote 2 functions:

#[no_mangle]
pub unsafe extern "C" fn exported_cmethod(env: &JNIEnv, obj: jobject, path: jstring) {
    // Some jni staff
}

And

#[no_mangle]
pub unsafe extern "stdcall" fn exported_stdmethod(env: &JNIEnv, obj: jobject, path: jstring) {
    // Some jni staff
}

And than I used dumpbin to see exports table

dumpbin /exports acc_check.dll | findstr exported
2094  82D 000014A0 exported_cmethod = __ZN4core3fmt5Write10write_char17h774b1da469bdbfa3E

So as you can see Rust exported C method but didn't export stdcall method

What I do wrong?


Solution

  • So I figured out how to fix this issue.
    I used gnu toolchain with MinGW and it was a mistake. I just downloaded MSVC toolchain with microsoft sdk and it solved my problem.