Mail Archives: cygwin/1997/04/04/14:31:41
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 <jni.h>
#include "HelloWorld.h"
#include <stdio.h>
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".
- Raw text -