Call fortran dll from java using JNI

Tierce

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...

Alex Cohn
  1. Prepare a Fifp.DEF file for the prebuilt Fortran DLL.

    LIBRARY Fifp.dll 
    EXPORTS
      RESET
    
  2. Create the LIB from DEF.

    lib /def:Fifp.DEF /OUT:Fifp.lib
    
  3. Build the FifpBridge.dll from myBridge.c and Fifp.LIB.

    cl /LD myBridge.c /link Fifp.LIB
    
  4. Change the Java statement to loadLibrary("FifpBridge"). The bridge will load the Fortran DLL without your intervention.

  5. Make sure both FifpBridge.dll and Fifp.dll are available at run time.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Using GetDirectBufferAddress from JNI

From Java

Overhead of a Java JNI call

From Java

Android ndk : Problem for call of Java method from c++ with jni

From Java

Java JNI call to load library

From Java

Build a JNI DLL using MINGW

From Java

Passing a pointer from JNI to Java using a long

From Java

Call C# dll from a Java Application

From

Calling Golang from Java using JNI on Windows leads to "A dynamic link library (DLL) initialization routine failed"

From Java

Can't call java methods from c++ wrapper in JNI

From Java

How To Call JAVA Methods from inside of a Thread in JNI

From Java

Call static Java method from separate thread using JNI

From Dev

Unable to make JNI call from c++ to java in android lollipop using jni

From Dev

Integration of Fortran code with Java by JNI

From Dev

Call a function in java from C outside of a JNI function (Android)?

From Dev

Call .dll functions using Java

From Dev

Call Java Enum method from JNI

From Dev

Call C dll from Fortran

From Dev

JNI Java using DLL function which takes an object as param

From Dev

Call a DLL from Haskell

From Dev

JNI to call .NET dll

From Dev

Call a JNI method from another JNI method

From Dev

JNI vs JNA, calling Java from Fortran95

From Dev

How to call a function with arguments in C++ from JAVA using JNI?

From Dev

Call a function of VB DLL file from java using JNA

From Dev

Call C# Method from C# Dll using Reflection

From Dev

How to call from jni java library with 2 string parameters?

From Dev

Java JNI call FindClass fails from a C++ program

From Dev

calling a fortran dll from python using cffi with multidimensional arrays

From Dev

Call DLL written in Delphi from Java

Related Related

HotTag

Archive