[英]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: 我的代码是:
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,我找到了文件夹
In this directories you can find the following header files: 在此目录中,您可以找到以下头文件:
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,则可以通过项目的属性添加这些包含目录:
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.