Visual C++ Error: LNK2019, LNK2028 and LNK1120(Visual C++ 错误:LNK2019、LNK2028 和 LNK1120)
问题描述
我正在开发一个基本应用程序,以创建 Java VM 并使用 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%Javajdk1.X.XX_XXlib
中找到它,然后您可以将其添加到链接器输入设置中.
It looks like you didn't link jvm.lib. You usually find it in %ProgramFiles%Javajdk1.X.XX_XXlib
, then you can add it to your linker input settings.
此外,您需要在运行时加载 jvm.dll(并将其添加到延迟加载的 dll 中).在 Windows 上,您可以从注册表中获取当前位置.在 SOFTWAREJavaSoftJava Runtime EnvironmentCurrentVersion
中查询当前运行时版本,在 SOFTWAREJavaSoftJava Runtime Environment
中查询 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 SOFTWAREJavaSoftJava Runtime EnvironmentCurrentVersion
for the current runtime version and SOFTWAREJavaSoftJava 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Visual C++ 错误:LNK2019、LNK2028 和 LNK1120
基础教程推荐
- 在螺旋中写一个字符串 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01