From: WESTER AT ilt DOT fhg DOT de ("R. Wester") Subject: Java Native Interface with gnu-win32 4 Apr 1997 14:31:41 -0800 Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <9704040828.AA00657.cygnus.gnu-win32@ee2s01.ilt.fhg.de> Reply-To: WESTER AT ilt DOT fhg DOT de Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT X-ENV: (mailgw1.fhg.de) WESTER AT ilt DOT fhg DOT de -> gnu-win32 AT cygnus DOT com DOT VIA-SMTP Comments: Authenticated sender is Original-To: gnu-win32 AT cygnus DOT com X-Mailer: Pegasus Mail for Win32 (v2.42a) Original-Sender: owner-gnu-win32 AT cygnus DOT com Hi, I tried to build a dll for using it from inside a Java class via the Java Native Interface. During compilation of the sample program from SUN's Java Tutorial (http://www.javasoft.com:80/nav/read/Tutorial/native1.1/stepbystep/ind ex.html): #include #include "HelloWorld.h" #include JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj) { printf("Hello world!\n"); return; } with gnu-win32 g++ I get a lot of error messages. Compiling with MVC++ works. In the Java (SUN JDK 1.1) include file jni.h there are statements like: jint (JNICALL *GetVersion)(JNIEnv *env); JNICALL is defined in win32/jni_md.h: #define JNICALL __stdcall Compiling the small sample code: int __attribute__ ((stdcall)) (*g)(int i); int __stdcall (*f)(int i); int __cdecl (*h)(int i); int (__attribute__ ((stdcall)) *g)(int i); int (__stdcall *f)(int i); int (__cdecl *h)(int i); with MVC++ and gnu-win32 g++ produces the following error messages: compile with MVC++ : .... test.cpp C:\Java11\classes\dll\test.cpp(1) : error C2065: 'stdcall' : undeclared identifier C:\Java11\classes\dll\test.cpp(1) : error C2501: '__attribute__' : missing decl-specifiers C:\Java11\classes\dll\test.cpp(1) : error C2143: syntax error : missing ';' before '(' C:\Java11\classes\dll\test.cpp(1) : error C2059: syntax error : ')' C:\Java11\classes\dll\test.cpp(1) : error C2143: syntax error : missing ')' before ';' C:\Java11\classes\dll\test.cpp(1) : error C2501: 'g' : missing decl-specifiers C:\Java11\classes\dll\test.cpp(2) : error C2059: syntax error : '(' C:\Java11\classes\dll\test.cpp(3) : error C2059: syntax error : '(' C:\Java11\classes\dll\test.cpp(5) : error C2199: syntax error : found 'int (' at global scope (was a declaration intended?) Error executing cl.exe. test.obj - 9 error(s), 0 warning(s) compile with gnu-win32 : g++ -c test.cpp test.cpp:5: syntax error befor '__attribute__' test.cpp:6: syntax error befor '__attribute__' test.cpp:7: syntax error befor '__attribute__' So MVC++ and gnu-win32 seem not to be compatible at this point: gnu_win32 : int __stdcall (*f)(int i); MVC : int (__stdcall *f)(int i); I would like to use gnu-win32 for building the dll's but it does'nt work as it is. I would be very appreciative for any help (including the statement that there is no work around for that problem). -- Rolf eMail: wester AT ilt DOT fhg DOT de ------------------------------------------------------------ # Rolf Wester # Fraunhofer Institut f. Lasertechnik # Steinbachstr. 15, D-52074 Aachen, Germany. # Tel: + 49 (0) 241 8906 0, Fax: +49 (0) 241 8906 121 # EMail: wester AT ilt DOT fhg DOT de, WWW: http://www.ilt.fhg.de - For help on using this list, send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".