[Mingw-users] mingw32 and jdk/jni

Back to archive index
Rastislav Stanik mingw****@rasto*****
Tue Sep 22 14:22:38 JST 2020


Hi Paul,

Do you #include "jni.h" in mary.c ?

What I've seen used in some projects is using dynamic
loading with

typedef int (*t_JNI_CreateJavaVM) (JavaVM**, void**, JavaVMInitArgs*);
...
t_JNI_CreateJavaVM *p=(t_JNI_CreateJavaVM) 
GetProcAddress(LoadLibrary(jvm_dll_path),"JNI_CreateJavaVM");

--
	bye
		rastos


On 22/09/2020 06.11, Paul Edwards wrote:
> 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);
> 
> _______________________________________________
> MinGW-Users mailing list
> MinGW****@lists*****
> 
> 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:mingw****@lists*****?subject=unsubscribe



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