* JNIEXPORT, JNICALL problems
@ 2005-07-28 21:05 Bowyer, Clifton C
0 siblings, 0 replies; only message in thread
From: Bowyer, Clifton C @ 2005-07-28 21:05 UTC (permalink / raw)
To: gcc-help
All,
I am trying to call a Fortran90 routine from a java class using
JNIEXPORT and JNICALL from Linux..
It looks like there is a problem in the calling protocol from c++ to
g95. Please read the e-mail.
Should I be using a different compiler preprocessor macro rather than -D
_FORTRAN_BUILD?
Your assistance would be greatly appreciated.
Thanks,
Cliff
1). The Fortran90 routine that I am trying to call in a java class has
the following definition:
subroutine APMCALC
I use the following command to make a shared object:
g95 -fPIC -fintrinsic-extensions -fcase-upper -r8 -shared -o
APMFortran.so apm_mod.f90 apmsubs.f90 apmcalc.f90
2). The JNIEXPORT .h and .cpp files to export the fortran subroutine
APMCALC are:
.h
* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class APMCalcJava */
extern "C" {
/*
* Class: APMCalcJava
* Method: APMCALC
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_APMCalcJava_APMCALC
(JNIEnv*, jobject);
}
.cpp
#include <jni.h>
#include "APMCalcJava.h"
//
//######################################################################
#####################
// APMCalcJava.cpp
//######################################################################
#####################
extern "C" void APMCALC_(void);
JNIEXPORT void JNICALL Java_APMCalcJava_APMCALC
(JNIEnv *env, jobject obj)
{
APMCALC_();
}
The c files are also made into a shared object with:
c++ -fPIC -D _FORTRAN_BUILD_ -shared -o libAPMCalcJava.so APMFortran.so
APMCalcJava.cpp
3). The java class that attempts to call APMCALC is:
package APMCalc;
import java.nio.charset.*;
import java.nio.*;
public class APMCalcJava implements Runnable
{
public APMCalcJava()
public void run()
{
System.out.println("Starting APM ...");
APMCALC();
System.out.println("Ending APM ...");
}
public static void main(String args[])
{
//
//create a APMCalcJava object instance
//
APMCalcJava APMRun = new APMCalcJava();
APMRun.run();
}
public native void APMCALC();
static
{
System.loadLibrary("APMCalcJava");
}
}
I run the java class with the following command and get the error:
java -classpath classes APMCalc.APMCalcJava
Starting APM ...
Exception in thread "main" java.lang.UnsatisfiedLinkError: APMCALC
at APMCalc.APMCalcJava.APMCALC(Native Method)
at APMCalc.APMCalcJava.run(APMCalcJava.java:42)
at APMCalc.APMCalcJava.main(APMCalcJava.java:63)
[
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-07-28 21:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-28 21:05 JNIEXPORT, JNICALL problems Bowyer, Clifton C
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).