简体   繁体   English

如何解决致命错误jvmti.h没有这样的文件或目录编译终止c代码ubuntu?

[英]how to fix fatal error jvmti.h No such file or directory compilation terminated c code ubuntu?

how to fix fatal error jvmti.h No such file or directory compilation terminated c code ubuntu? 如何解决致命错误jvmti.h没有这样的文件或目录编译终止c代码ubuntu? my c code is: 我的代码是:

include "jvmti.h" 包括“jvmti.h”

JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM * jvm,char * options,void * reserved){

/* We return JNI_OK to signify success */ printf("\\nmy name is,\\n\\n"); / *我们返回JNI_OK表示成功* / printf(“\\ n name name,\\ n \\ n”);

return JNI_OK; 返回JNI_OK;

} }

JNIEXPORT void JNICALL Agent_OnUnload(JavaVM *vm) { } JNIEXPORT void JNICALL Agent_OnUnload(JavaVM * vm){}

type this command in terminal: gcc -Wall -W -Werror first_agent.c -o firstagent 在终端中输入以下命令:gcc -Wall -W -Werror first_agent.c -o firstagent

first_agent.c:1:19: fatal error: jvmti.h: No such file or directory compilation terminated. first_agent.c:1:19:致命错误:jvmti.h:没有终止此类文件或目录编译。

where java jdk version javac 1.7.0_25 其中java jdk版本为javac 1.7.0_25

where gcc version gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-2ubuntu4) 其中gcc版本gcc版本4.7.3(Ubuntu / Linaro 4.7.3-2ubuntu4)

here should update gcc version to 4.8? 这里应该将gcc版本更新到4.8?

This question is now pretty old, but probably someone will stumble across this in the future. 这个问题现在已经很老了,但未来可能有人会偶然发现这个问题。

As @Gyro Gearless already mentioned, you need to specify the "Include directories". 正如@Gyro Gearless已经提到的,您需要指定“包含目录”。

For Java 8 on Ubuntu 15.04 I found the folders at 对于Ubuntu 15.04上的Java 8,我找到了文件夹

  • /usr/lib/jvm/java-1.8.0-openjdk-amd64/include /usr/lib/jvm/java-1.8.0-openjdk-amd64/include
  • /usr/lib/jvm/java-1.8.0-openjdk-amd64/include/linux /usr/lib/jvm/java-1.8.0-openjdk-amd64/include/linux

In this directories you can find the following header files: 在此目录中,您可以找到以下头文件:

  • classfile_constants.h classfile_constants.h
  • jawt.h jawt.h
  • jdwpTransport.h jdwpTransport.h
  • jni.h jni.h
  • jvmticmlr.h jvmticmlr.h
  • jvmti.h jvmti.h

which are needed by the compiler to include. 编译器需要包含哪些内容。

If you are using Netbeans you can add those include directory via the properties of your project: 如果您使用的是Netbeans,则可以通过项目的属性添加这些包含目录: 右键单击Project并选择“Properties”

You need to tell gcc where it can find its include files using -I option. 你需要告诉gcc它可以使用-I选项找到它的包含文件。 Here is a sample invocation for building a JNI library. 以下是用于构建JNI库的示例调用。 Note this was automatically created from some Maven plugin on Windows, so it is a bit noisy: 注意这是从Windows上的一些Maven插件自动创建的,所以有点吵:

g++ -m64 -shared -IC:\work\Produktiv\jdpapi\jdpapi-native\src\main\native 
 -IC:\work\Produktiv\jdpapi\jdpapi-native\target\native\javah 
 -IC:\opt\Java\jdk1.7.0_40\jre\..\include 
 -IC:\opt\Java\jdk1.7.0_40\jre\..\include\win32 
 -o C:\work\Produktiv\jdpapi\jdpapi-native\target\objs\DPAPI.obj 
 -c C:\work\Produktiv\jdpapi\jdpapi-native\src\main\native\DPAPI.cpp

Note this is really just one line; 注意这只是一行; and of course you have to adjust the paths for Linux :-) 当然你必须调整Linux的路径:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JNI.h与JVMTi.h的比较 - Implmentation of JNI.h vs JVMTi.h 致命错误:jni.h:没有这样的文件或目录 - fatal error: jni.h: No such file or directory Makefile:致命错误:jni.h:没有这样的文件或目录 - Makefile: Fatal error: jni.h: No such file or directory 致命错误:jni.h:安装jPype时没有此类文件或目录 - Fatal error: jni.h: No such file or directory while installing jPype 严重错误:jni.h:没有此类文件或目录Netbeans IDE - fatal error: jni.h: No such file or directory Netbeans IDE 致命错误:webkit2 / webkit2.h:没有这样的文件或目录 - fatal error: webkit2/webkit2.h: No such file or directory 出现致命错误:jni.h:没有这样的文件或目录#include <jni.h> - Getting fatal error: jni.h: No such file or directory #include <jni.h> 致命错误:jni_md.h:没有这样的文件或目录#include “jni_md.h” - fatal error: jni_md.h: No such file or directory #include “jni_md.h” 在Ubuntu上启动Eclipse时出错,JVM终止退出代码= 13 - Error starting Eclipse on Ubuntu, JVM terminated Exit code=13 在 Rust 项目的 C 绑定上运行 jextract 时出现致命错误“'stdlib.h'文件未找到” - Fatal error “'stdlib.h' file not found” when running jextract on the C binding for a Rust project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM