I have a Fifp.dll in fortran with a simple void RESET()
function and try to call it from my Java code.
I made a simple java test class:
public class TestJni {
static {
System.loadLibrary("Fifp");
}
public native void RESET();
}
I made a .h file from it, and compiled it. I also made a bridge file myBridge.c:
#include <stdio.h>
#include "TestJni.h"
extern void RESET();
JNIEXPORT void JNICALL Java_TestJni_RESET(JNIEnv *env, jobject obj) {
printf("Before DLL call\n");
RESET();
printf("After DLL call\n");
}
Now I'm not able to compile it. This is the command I tried in a Visual Studio x64 comand prompt:
> cl -I"C:\path\to\jdk\include\win32" -I"C:\path\to\jdk\include" myBridge.c
and also with a -FeFifp.dll
option, it gives me the same error:
LNK2019: unresolved external symbol RESET (and main)
So what am I doing wrong ?
Is there an option to specify the external dll to include ?
Am I in the right way to perform the new TestJni().RESET()
call ?
Any help appreciated...
Prepare a Fifp.DEF file for the prebuilt Fortran DLL.
LIBRARY Fifp.dll
EXPORTS
RESET
Create the LIB from DEF.
lib /def:Fifp.DEF /OUT:Fifp.lib
Build the FifpBridge.dll from myBridge.c and Fifp.LIB.
cl /LD myBridge.c /link Fifp.LIB
Change the Java statement to loadLibrary("FifpBridge"). The bridge will load the Fortran DLL without your intervention.