JNI unresolved external symbol __imp_JNI_CreateJavaVM in a 64-bit compiler

I am trying to create a JVM usin JNI. I am using win 7 64-bit OS. On the JNI_CreateJavaVM line, my program crashes. I decided to compile my program using a 64-bit compiler and received the following error:

Error 1 error LNK2001: unresolved external symbol __imp_JNI_CreateJavaVM

Where should I start looking for a binding problem and why does my program crashes in 32-bit mode?

 void createJVM() { JavaVMInitArgs vm_args; JavaVMOption options[4]; int n = 0; char * str; str= new char[1000]; sprintf(str, "-Djava.class.path=%S\\tst.jar", myPath); options[n++].optionString = str; str= new char[1000]; sprintf(str, "-Djava.library.path=%S\\lib;%S", myPath, myPath); options[n++].optionString = str; str= new char[1000]; sprintf(str, "-Duser.dir=%S", myPath); options[n++].optionString = str; vm_args.version = JNI_VERSION_1_4; vm_args.nOptions = n; vm_args.options = options; vm_args.ignoreUnrecognized = false; JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args); } 
+4
source share
2 answers

Have you added 'jvm.lib' as an additional dependency in your project? in addition, you need to specify the location of jvm.lib in additional library directories ...

also note that for a 64-bit application you need to point to a 64-bit library, otherwise the linker will not link to

These parameters can be found in the "Configuration Properties →" area.

Hope this information helps you.

Greetings

+4
source

Since I cannot calculate (even less than 15 reputations), I just want to confirm that the Naytzyrhc solution worked for me.

To clarify this a bit, in Visual Studio Express 2013 (v12) you should go to:

 Project -> [YourProjectName] Properties... -> Linker -> General -> Additional Library Directories 

to add the lib folder to additional library directories and:

 Project -> [YourProjectName] Properties... -> Linker -> Input -> Additional Dependencies 

to add jvm.lib to additional dependencies.

0
source

Source: https://habr.com/ru/post/1435474/


All Articles