This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project. See the Cygwin home page for more information.
Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: jni,egcs1.1.2 compiling problem


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