【问题标题】:JMVTI:Could not find agent libraryJMVTI:找不到代理库
【发布时间】:2015-09-16 10:25:45
【问题描述】:

我为 Java 编写了一个代理,它什么都不做,只导出两个方法,只是为了检查它是否在 JVM 启动时加载。使用 mingw-w64 4.8.4(使用 JetBrains CLion)构建它。 Windows 7 x64。

JNIEXPORT jint JNICALL
Agent_OnLoad(JavaVM *jvm, char *options, void *reserved){
  return JNI_OK;
}

JNIEXPORT void JNICALL
Agent_OnUnload(JavaVM *vm){}

运行时出错

java -agentlib:"C:\JMVAgent\agent.dll"

Error occurred during initialization of VM
Could not find agent library libSampleAgent.dll on the library path, 
with error: Can't find dependent libraries

我还将 agent.dll 放入 c:\windows\System32 并运行 java w/o agent full path 得到相同的结果。

DependencyWalker 没有显示依赖错误

请帮忙找出我做错了什么

【问题讨论】:

  • 你是如何编译 .dll 的?请注意,如果您要指定代理库的完整路径,请使用 -agentpath 而不是 -agentlib
  • 我不明白你关于编译的问题,你对什么感兴趣? -agentpath 有帮助,非常感谢!
  • 我的意思是命令行,你是如何从源代码构建 .dll 的。但是没关系。既然agentpath 解决了这个问题,我就把这个作为答案。

标签: java jvm jvmti


【解决方案1】:

如果您要指定代理库的完整路径,请使用-agentpath 而不是-agentlib

区别解释here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-07-08
    • 2019-12-23
    • 2020-09-12
    • 1970-01-01
    • 2017-03-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-09
    相关资源
    最近更新 更多