我在写一些使用jni的代码。我的目标平台是Windows。因此,我的jni函数必须使用stdcall调用约定,但Rust只使用cdecl调用约定导出函数。
我使用MinGW(可能很重要)
我写了两个函数:
#[no_mangle]
pub unsafe extern "C" fn exported_cmethod(env: &JNIEnv, obj: jobject, path: jstring) {
// Some jni staff
}和
#[no_mangle]
pub unsafe extern "stdcall" fn exported_stdmethod(env: &JNIEnv, obj: jobject, path: jstring) {
// Some jni staff
}比我用垃圾箱看到的导出表还要多
dumpbin /exports acc_check.dll | findstr exported
2094 82D 000014A0 exported_cmethod = __ZN4core3fmt5Write10write_char17h774b1da469bdbfa3E因此,您可以看到,Rust导出了C方法,但没有导出stdcall
我做错了什么?
发布于 2019-09-09 12:38:34
所以我想出了如何解决这个问题。
我在MinGW中使用了,这是一个错误。我刚刚用microsoft下载了MSVC工具链,它解决了我的问题。
https://stackoverflow.com/questions/57840984
复制相似问题