如何修复致命错误jvmti。没有这样的文件或目录编译终止了c代码ubuntu?

时间:2021-06-10 09:39:24

how to fix fatal error jvmti.h No such file or directory compilation terminated c code ubuntu? my c code is:

如何修复致命错误jvmti。没有这样的文件或目录编译终止了c代码ubuntu?我的c代码是:

include "jvmti.h"

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

JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *选项,void *预留){

/* We return JNI_OK to signify success */ printf("\nmy name is,\n\n");

/*我们返回JNI_OK表示成功*/ printf(“\nmy name is,\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版本4.7.3 (Ubuntu/Linaro 4.7.3-2ubuntu4)

here should update gcc version to 4.8?

这里应该更新gcc版本到4.8?

2 个解决方案

#1


4  

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已经提到的,您需要指定“Include目录”。

For Java 8 on Ubuntu 15.04 I found the folders at

在ubuntu15.04上的Java 8,我找到了文件夹。

  • /usr/lib/jvm/java-1.8.0-openjdk-amd64/include
  • /usr/lib/jvm/java-1.8.0-openjdk-amd64 /包括
  • /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: 如何修复致命错误jvmti。没有这样的文件或目录编译终止了c代码ubuntu?

如果您正在使用Netbeans,您可以通过您的项目的属性来添加那些包括目录:

#2


2  

You need to tell gcc where it can find its include files using -I option. Here is a sample invocation for building a JNI library. Note this was automatically created from some Maven plugin on Windows, so it is a bit noisy:

您需要告诉gcc在哪里可以找到它的包含文件,使用-I选项。下面是构建JNI库的示例调用。注意,这是由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的路径:-)

#1


4  

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已经提到的,您需要指定“Include目录”。

For Java 8 on Ubuntu 15.04 I found the folders at

在ubuntu15.04上的Java 8,我找到了文件夹。

  • /usr/lib/jvm/java-1.8.0-openjdk-amd64/include
  • /usr/lib/jvm/java-1.8.0-openjdk-amd64 /包括
  • /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: 如何修复致命错误jvmti。没有这样的文件或目录编译终止了c代码ubuntu?

如果您正在使用Netbeans,您可以通过您的项目的属性来添加那些包括目录:

#2


2  

You need to tell gcc where it can find its include files using -I option. Here is a sample invocation for building a JNI library. Note this was automatically created from some Maven plugin on Windows, so it is a bit noisy:

您需要告诉gcc在哪里可以找到它的包含文件,使用-I选项。下面是构建JNI库的示例调用。注意,这是由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的路径:-)