[Mingw-users] mingw32 and jdk/jni

Back to archive index
Paul Edwards mutaz****@gmail*****
Tue Sep 22 13:11:16 JST 2020


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 at 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 at 12
         U __IMPORT_DESCRIPTOR_jvm
00000000 T _JNI_CreateJavaVM at 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 at 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);



More information about the MinGW-Users mailing list
Back to archive index