delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/04/21/22:21:09

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Message-Id: <371E86BD.91C757B9@tempest.engr.ucdavis.edu>
Date: Wed, 21 Apr 1999 19:17:33 -0700
From: John McNally <mcnally AT tempest DOT engr DOT ucdavis DOT edu>
X-Mailer: Mozilla 4.5 [en] (Win95; I)
X-Accept-Language: en
Mime-Version: 1.0
To: Mumit Khan <khan AT xraylith DOT wisc DOT edu>,
"gnu-win32 AT cygnus DOT com" <gnu-win32 AT cygnus DOT com>
Subject: Re: jni,egcs1.1.2 compiling problem
References: <Pine DOT SUN DOT 3 DOT 93 DOT 990421183836 DOT 11231L-101000 AT modi DOT xraylith DOT wisc DOT edu>

Thank you for all your help.  Your Fortran JNI example worked fine as
delivered.  However I tried making the fortran function have an integer
in its argument list.  If the function does nothing with the integer
passed to it it will return ok.  If the integer is used in the function,
however, the program crashes.

This does not appear to be related to JNI, but in calling the Fortran
routine from C.  I'm sure this sort of thing must have been ironed out
long ago, so it is probably the way I'm doing it.
I did try compiling with the -mrtd option.  I'll try some more tomorrow.


f77func.f
************************************************
	function f77func (ii)
	implicit none
	integer f77func,ii
c  Note:  the following line produces a runtime error as does any
c         other operation using ii (e.g. ii=ii+1)
      f77func = ii
      write (*,*) 'f77func: Returning ',f77func
c
	return 
	end

HelloWorldImp.c
**********************************************

#include <stdio.h>
#include <stdlib.h>
#include <jni.h>
#include "HelloWorld.h"

/* most f77 compilers tack a underscore after the function name. */
#define F77_FUNCTION(f) f##_

extern int F77_FUNCTION(f77func) (int ii);

JNIEXPORT void JNICALL 
Java_HelloWorld_displayHelloWorld (JNIEnv *env, jobject obj) 
{
  
  char *home;
  int i=5;
  printf("Java JNI\n");
  home = getenv ("HOME");
  printf("HOME = %s\n", (home) ? home : "(NULL)");
  printf("f77func returned %d\n", F77_FUNCTION(f77func) (i));
  
  return;
}

Mumit Khan wrote:

> I'm sending an example of f77 code JNI. You'll get a directory named 'f'
> when you untar the package (tar zxvf java-jni-f77.tar.gz), and then use
> the ``make -f Makefile.cyg'' to build the hello.dll.
> 
> Regards,
> Mumit
> 

-- 
John McNally
Graduate Student, UCLA
Graduate Student Researcher, UC-Davis
e-mail: mcnally AT tempest DOT engr DOT ucdavis DOT edu

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019