This is the mail archive of the
java-prs@gcc.gnu.org
mailing list for the Java project.
[Bug java/28153] New: Under Windows Xp the generated JNI headers need to have a '_' prepended for each function.
- From: "bcmpinc at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: java-prs at gcc dot gnu dot org
- Date: 24 Jun 2006 16:21:24 -0000
- Subject: [Bug java/28153] New: Under Windows Xp the generated JNI headers need to have a '_' prepended for each function.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I had some problems when I tried to compile a JNI-example from wikipedia:
http://en.wikipedia.org/wiki/JNI
I compiled the Java-source containing the native function
with 'gcj -C' (gcc version 3.4.2 (mingw-special)):
public native void sayHello();
I passed the class-file to 'gcjh -jni' and it produced a header with the line:
extern JNIEXPORT void JNICALL Java_JavaSide_sayHello (JNIEnv *env, jobject);
I implemented the function, compiled it with 'g++ -O2 -shared'
When I tried to run the java class it gave an error when it called the native
function.
I examined some other dll's used by java (with depens.exe) and all the
functions
had a '_' prepended.
I changed the line in the header file to:
extern JNIEXPORT void JNICALL _Java_JavaSide_sayHello (JNIEnv *env, jobject);
Recompiled the C++ source and ran the java class. This time the function worked
without any problems.
--
Summary: Under Windows Xp the generated JNI headers need to have
a '_' prepended for each function.
Product: gcc
Version: 3.4.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: java
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bcmpinc at hotmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28153