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]

jni,egcs1.1.2 compiling problem


I am trying to call a native method within Java using the jni examples
from Mumit Khan's website.  I'm not very knowledgable about C, so I'm
hoping I'm making a rather easy to see error.  But possibly it is
something more subtle and my reporting of the error may help others.

I should also note the native method is in fortran and I expected that
it may not work, however, I believe the problems I am having are
unrelated to this (they will probably show up when linking while running
the java class).  And nothing in what follows is related to the fortran
code.

When compiling I attempt to add the header files to the dllinit.c file
which is part of Mumit Khan's examples on building a DLL.

Using win95, egcs1.1.2-mingw32, jdk1.1.5 I get the following error. 

A:\>gcc -c -DBUILDING_DLL=1 -I. -Ic:/Languages/Java/jdk1.1.5/include
-Ic:/Langua
ges/Java/jdk1.1.5/include/win32 -o dllinit.o dllinit.c
In file included from c:\Languages\Java\jdk1.1.5\include\typedefs.h:26,
                 from c:\Languages\Java\jdk1.1.5\include\oobj.h:33,
                 from c:\Languages\Java\jdk1.1.5\include\native.h:34,
                 from GyroIn.h:2,
                 from dllinit.c:35:
c:\Languages\Java\jdk1.1.5\include\win32\typedefs_md.h:67: `#' operator
is not f
ollowed by a macro argument name
c:\Languages\Java\jdk1.1.5\include\win32\typedefs_md.h:67: `#' operator
is not f
ollowed by a macro argument name

Using Nt, egcs1.1.2-mingw32, and jdk1.1.8 I get a long list of different
errors which I will place at the end of this message in case they are
more help, but first, here are the files


dllinit.c
********************************************************************
 
#include <jni.h>      // only changes to file
#include "GyroIn.h"


#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#include <stdio.h>
                            //I also tried placing the includes here.

BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, 
                       LPVOID reserved /* Not used. */ );

/*
 *----------------------------------------------------------------------
 *
 * DllMain --
 *
 *	This routine is called by the Mingw32, Cygwin32 or VC++ C run 
 *	time library init code, or the Borland DllEntryPoint routine. It 
 *	is responsible for initializing various dynamically loaded 
 *	libraries.
 *
 * Results:
 *      TRUE on sucess, FALSE on failure.
 *
 * Side effects:
 *
 *----------------------------------------------------------------------
 */
BOOL APIENTRY
DllMain (
	 HINSTANCE hInst /* Library instance handle. */ ,
	 DWORD reason /* Reason this function is being called. */ ,
	 LPVOID reserved /* Not used. */ )
{

  switch (reason)
    {
    case DLL_PROCESS_ATTACH:
      break;

    case DLL_PROCESS_DETACH:
      break;

    case DLL_THREAD_ATTACH:
      break;

    case DLL_THREAD_DETACH:
      break;
    }
  return TRUE;
}

GyroIn.h
******************************************************

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <native.h>
/* Header for class GyroIn */

#ifndef _Included_GyroIn
#define _Included_GyroIn

#pragma pack(4)

typedef struct ClassGyroIn {
    char PAD;	/* ANSI C requires structures to have a least one member
*/
} ClassGyroIn;
HandleTo(GyroIn);

#pragma pack()

#ifdef __cplusplus
extern "C" {
#endif
extern void GyroIn_mainprog(struct HGyroIn
*,long,long,long,long,float,long,long,long,HArrayOfInt *,HArrayOfFloat
*,HArrayOfFloat *,HArrayOfFloat *,HArrayOfFloat
*,float,float,float,float,long,long,long,long,long,long,float,float,float,HArrayOfInt
*,HArrayOfFloat *,long,float,float,long,float,float,long,float,float);
#ifdef __cplusplus
}
#endif
#endif



GyroIn.java
********************************************************************
class GyroIn {

    static {
        System.loadLibrary("f77dll");
    }


    public native void mainprog(int ipmore,int iplot,int
icavnm,int                               icavmx,float fghz,int im,int
il,int is,int[] iin,float[] aqcav,float[] llamcv,float[] llamdf,float[]
offset,float drc,float rcavg,float alpha0,
float ribamp,int izstep,int itmax,int ircmax,int ipsimx,int iphimx,int
ipzmax,float eomin,float tz,float dz,int[] ineo,float[] base,int
iwmax,float dwmin,float dwmax,int idsmax,float b0kgmn,float b0kgmx,int
ivbkvmx,float vbmin,float vbmax);

    public static void main(String[] args) {
int ipmore=1;
...
initialize all variables // removed for some brevity
...
float vbmax=80.0f;

       GyroIn g = new GyroIn();
       g.mainprog(ipmore,iplot,icavnm,icavmx,fghz,im,il,is,
                  iin,aqcav,llamcv,llamdf,offset,drc,rcavg,alpha0,
                  ribamp,izstep,itmax,ircmax,ipsimx,iphimx,ipzmax,
                  eomin,tz,dz,ineo,base,iwmax,dwmin,dwmax,idsmax,
                  b0kgmn,b0kgmx,ivbkvmx,vbmin,vbmax);
}
}


Finally, the output while compiling on Nt, with egcs1.1.2-mingw32 and
jdk1.1.8


D:\USERS\MCNALLY\programs\java>gcc -c -DBUILDING_DLL=1 -I.
-Id:/language/java/jd
k1.1.8/include -Id:/language/java/jdk1.1.8/include/win32 -o dllinit.o
dllinit.c

In file included from d:\language\java\jdk1.1.8\include\typedefs.h:18,
                 from d:\language\java\jdk1.1.8\include\oobj.h:25,
                 from d:\language\java\jdk1.1.8\include\native.h:26,
                 from GyroIn.h:2,
                 from dllinit.c:39:
d:\language\java\jdk1.1.8\include\win32\typedefs_md.h:29: parse error
before `in
t64_t'
d:\language\java\jdk1.1.8\include\win32\typedefs_md.h:29: warning: data
definiti
on has no type or storage class
d:\language\java\jdk1.1.8\include\win32\typedefs_md.h:30: parse error
before `ui
nt64_t'
d:\language\java\jdk1.1.8\include\win32\typedefs_md.h:30: warning: data
definiti
on has no type or storage class
d:\language\java\jdk1.1.8\include\win32\typedefs_md.h:65: parse error
before `fl
oat2ll'
d:\language\java\jdk1.1.8\include\win32\typedefs_md.h:65: warning: data
definiti
on has no type or storage class
d:\language\java\jdk1.1.8\include\win32\typedefs_md.h:66: parse error
before `do
uble2ll'
d:\language\java\jdk1.1.8\include\win32\typedefs_md.h:66: warning: data
definiti
on has no type or storage class
d:\language\java\jdk1.1.8\include\win32\typedefs_md.h:84: parse error
before `a'

d:\language\java\jdk1.1.8\include\win32\typedefs_md.h:85: parse error
before `ll
_shl'
d:\language\java\jdk1.1.8\include\win32\typedefs_md.h:85: parse error
before `a'

d:\language\java\jdk1.1.8\include\win32\typedefs_md.h:85: warning: data
definiti
on has no type or storage class
In file included from d:\language\java\jdk1.1.8\include\oobj.h:25,
                 from d:\language\java\jdk1.1.8\include\native.h:26,
                 from GyroIn.h:2,
                 from dllinit.c:39:
d:\language\java\jdk1.1.8\include\typedefs.h:31: parse error before
`int64_t'
d:\language\java\jdk1.1.8\include\typedefs.h:31: warning: no semicolon
at end of
 struct or union
d:\language\java\jdk1.1.8\include\typedefs.h:33: parse error before `}'
d:\language\java\jdk1.1.8\include\typedefs.h:33: warning: data
definition has no
 type or storage class
In file included from d:\language\java\jdk1.1.8\include\native.h:26,
                 from GyroIn.h:2,
                 from dllinit.c:39:
d:\language\java\jdk1.1.8\include\oobj.h:55: parse error before `number'
d:\language\java\jdk1.1.8\include\oobj.h:160: parse error before
`int64_t'
d:\language\java\jdk1.1.8\include\oobj.h:160: warning: no semicolon at
end of st
ruct or union
d:\language\java\jdk1.1.8\include\oobj.h:161: warning: data definition
has no ty
pe or storage class
d:\language\java\jdk1.1.8\include\oobj.h:162: parse error before
`ClassArrayOfLo
ng'
d:\language\java\jdk1.1.8\include\oobj.h:162: warning: data definition
has no ty
pe or storage class
d:\language\java\jdk1.1.8\include\oobj.h:163: parse error before
`ClassArrayOfLo
ng'
d:\language\java\jdk1.1.8\include\oobj.h:163: warning: no semicolon at
end of st
ruct or union
d:\language\java\jdk1.1.8\include\oobj.h:163: parse error before `}'
d:\language\java\jdk1.1.8\include\oobj.h:163: warning: data definition
has no ty
pe or storage class
In file included from d:\language\java\jdk1.1.8\include\native.h:27,
                 from GyroIn.h:2,
                 from dllinit.c:39:
d:\language\java\jdk1.1.8\include\interpreter.h:260: parse error before
`TotalOb
jectMemory'
d:\language\java\jdk1.1.8\include\interpreter.h:260: warning: data
definition ha
s no type or storage class
d:\language\java\jdk1.1.8\include\interpreter.h:261: parse error before
`FreeObj
ectMemory'
d:\language\java\jdk1.1.8\include\interpreter.h:261: warning: data
definition ha
s no type or storage class
d:\language\java\jdk1.1.8\include\interpreter.h:262: parse error before
`TotalHa
ndleMemory'
d:\language\java\jdk1.1.8\include\interpreter.h:262: warning: data
definition ha
s no type or storage class
d:\language\java\jdk1.1.8\include\interpreter.h:263: parse error before
`FreeHan
dleMemory'
d:\language\java\jdk1.1.8\include\interpreter.h:263: warning: data
definition ha
s no type or storage class

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