Reputation: 101
how to fix fatal error jvmti.h No such file or directory compilation terminated c code ubuntu? my c code is:
JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) {
/* We return JNI_OK to signify success */ printf("\nmy name is,\n\n");
return JNI_OK;
}
JNIEXPORT void JNICALL Agent_OnUnload(JavaVM *vm) { }
type this command in terminal: 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.
where java jdk version javac 1.7.0_25
where gcc version gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-2ubuntu4)
here should update gcc version to 4.8?
Upvotes: 5
Views: 4706
Reputation: 12658
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".
For Java 8 on Ubuntu 15.04 I found the folders at
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:
Upvotes: 5
Reputation: 5279
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:
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 :-)
Upvotes: 2