jni,egcs1.1.2 compiling problem

John McNally mcnally@tempest.engr.ucdavis.edu
Wed Apr 21 19:20:00 GMT 1999


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@tempest.engr.ucdavis.edu

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com



More information about the Cygwin mailing list