简体   繁体   中英

What library to link to on Windows 7 for JNI_CreateJavaVM?

I am building a first working version of a JNI application in C++. I do not believe the specific details of the application are important for this question. If they are, I will append them.

My code compiles without error. However, there is a single linker error:

error LNK2019: unresolved external symbol __imp__JNI_CreateJavaVM@12

I understand that JNI_CreateJavaVM is not included in jvm.lib / jvm.dll . However, I cannot determine what library I do need to link to for this function.

I have JDK installed (but only 64-bit - and this is a 32-bit C++ application, which may be relevant).

Can somebody please assist?

Steps to link the jvm.lib to your project in Visual Studio:

  • Right click on the project -> properties.
  • On the Properties dialog box, add jvm.lib under Linker->Input->AdditionalDependencies area.
  • Lastly write jvm.lib path(like "C:\\Program
    Files\\Java\\jdk1.7.0_60\\lib") under
    Linker->General->AdditionalLibraryDirectories

After those steps, your project can link to jvm and work well.

如果要从C ++运行Java应用程序,我建议使用exec并创建一个新的进程esp(如果一个是32位,另一个是64位)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM