mingw32 and jdk/jni

"Paul Edwards" <[email protected]> Tue, 22 Sep 2020 14:11:16 +1000
Newsgroups gmane.comp.gnu.mingw.user
Message-ID <AFFB48AC5C4345868CBF8D3CEB8B58A3@DESKTOP0OKG1VA>
Hello.

I am trying to get a mingw32 program to call Java,
using JNI. I am getting an error about not being
able to find _imp__JNI_CreateJavaVM@12

I have got conflicting information from the web
as to whether the jvm.lib that is supplied in the
JDK should work or not. Some information says
that it won't work, because the function is
stdcall and mingw32 does not prefix the function
name with an underscore, while MSVC does.

Note that the above reference only has one
underscore, instead of the two that show up
when running "nm" on jvm.lib:

00000000 I __imp__JNI_CreateJavaVM@12
         U __IMPORT_DESCRIPTOR_jvm
00000000 T _JNI_CreateJavaVM@12

I have tried a lot of searches and a lot of
experiments, but nothing successful. I still
can't even answer the basic question of
whether it is meant to work out of the box
or not. Or whether I need to construct my
own "lib" file. Any ideas? Relevant technical
info below.

Thanks. Paul.


C:\paul\devel\jnitest>mingw32-make
mingw32-gcc -o mary.exe \
-L "C:\Program Files (x86)\Java\jdk1.8.0_221\lib" \
-ljvm \
-I "C:\Program Files (x86)\Java\jdk1.8.0_221\include" \
-I "C:\Program Files (x86)\Java\jdk1.8.0_221\include\win32" \
mary.c

c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: 
C:\Users\xxx\AppData\Local\Temp\ccqlQomh.o:mary.c:(.text+0x3c): undefined 
reference to `_imp__JNI_CreateJavaVM@12'
collect2.exe: error: ld returned 1 exit status
Makefile:7: recipe for target 'mary.exe' failed
mingw32-make: *** [mary.exe] Error 1


C:\paul\devel\jnitest>mingw32-gcc --version
mingw32-gcc (MinGW.org GCC-8.2.0-5) 8.2.0


mary.c:

ret = JNI_CreateJavaVM(&jvm, (void**)&env, &args);

_______________________________________________
MinGW-Users mailing list
[email protected]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.osdn.me/mailman/listinfo/mingw-users
Also: mailto:[email protected]?subject=unsubscribe