Visual C ++错误:LNK2019,LNK2028和LNK1120 [英] Visual C++ Error: LNK2019, LNK2028 and LNK1120

查看:1294
本文介绍了Visual C ++错误:LNK2019,LNK2028和LNK1120的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个基本的应用程序来创建一个Java虚拟机并使用JNI从C ++启动一个Java程序。但是,我有一些编译错误:

I'm working on a basic application to create a Java VM and launch a Java program from C++ with JNI. However, I have some compiling errors:

Error   6   error LNK2028: unresolved token (0A00000D) "extern "C" long __stdcall JNI_CreateJavaVM(struct JavaVM_ * *,void * *,void *)" (?JNI_CreateJavaVM@@$$J212YGJPAPAUJavaVM_@@PAPAXPAX@Z) referenced in function "public: bool __clrcall JarLauncher::launchJar(void)" (?launchJar@JarLauncher@@$$FQ$AAM_NXZ)  
Error   5   error LNK2028: unresolved token (0A00000C) "extern "C" long __stdcall JNI_GetDefaultJavaVMInitArgs(void *)" (?JNI_GetDefaultJavaVMInitArgs@@$$J14YGJPAX@Z) referenced in function "public: bool __clrcall JarLauncher::launchJar(void)" (?launchJar@JarLauncher@@$$FQ$AAM_NXZ)      
Error   7   error LNK2019: unresolved external symbol "extern "C" long __stdcall JNI_GetDefaultJavaVMInitArgs(void *)" (?JNI_GetDefaultJavaVMInitArgs@@$$J14YGJPAX@Z) referenced in function "public: bool __clrcall JarLauncher::launchJar(void)" (?launchJar@JarLauncher@@$$FQ$AAM_NXZ)   
Error   8   error LNK2019: unresolved external symbol "extern "C" long __stdcall JNI_CreateJavaVM(struct JavaVM_ * *,void * *,void *)" (?JNI_CreateJavaVM@@$$J212YGJPAPAUJavaVM_@@PAPAXPAX@Z) referenced in function "public: bool __clrcall JarLauncher::launchJar(void)" (?launchJar@JarLauncher@@$$FQ$AAM_NXZ)   
Error   9   error LNK1120: 4 unresolved externals   

任何帮助?

推荐答案

看起来您没有链接 jvm.lib 。您通常在%ProgramFiles%\Java\jdk1.X.XX_XX\lib 中找到它,然后可以将其添加到链接器输入设置。

It looks like you didn't link jvm.lib. You usually find it in %ProgramFiles%\Java\jdk1.X.XX_XX\lib, then you can add it to your linker input settings.

此外,您需要在运行时加载 jvm.dll (并将其添加到延迟加载的dll)。在Windows上,您可以从注册表获取当前位置。查询 SOFTWARE \JavaSoft\Java Runtime Environment \ CurrentVersion 为当前运行时版本和 SOFTWARE\JavaSoft\Java运行环境\ ; version> \RuntimeLib 为jvm.dll的路径。

Also, you'll need to load jvm.dll at runtime (and add it to the delay loaded dlls). On Windows, you can get the current location from the registry. Query SOFTWARE\JavaSoft\Java Runtime Environment\CurrentVersion for the current runtime version and SOFTWARE\JavaSoft\Java Runtime Environment\<version>\RuntimeLib for the path of jvm.dll.

使用这些路径,您还可以检查系统上是否存在所需的运行时版本。

Using those paths you can also check if the required runtime version is present on the system.

这篇关于Visual C ++错误:LNK2019,LNK2028和LNK1120的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆