java 致命错误:jni_md.h:没有这样的文件或目录#include "jni_md.h"

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37023234/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 02:07:17  来源:igfitidea点击:

fatal error: jni_md.h: No such file or directory #include "jni_md.h"

javac++clinuxgcc

提问by Manjunath

While executing gcccommand on ubuntu for generating .a or .so file for JNI, getting below error for both openjdk 8 / oraclejdk8.

gcc在 ubuntu 上执行命令为 JNI 生成 .a 或 .so 文件时,openjdk 8 / oraclejdk8 都出现以下错误。

$gcc -I/usr/lib/jvm/java-8-openjdk-amd64/include -c MainImpl1.c -o MainImpl1.o

In file included from MainImpl1.c:1:0:
/usr/lib/jvm/java-8-openjdk-amd64/include/jni.h:45:20: fatal error: jni_md.h: No such file or directory
 #include "jni_md.h"
                ^
compilation terminated.

$gcc -I/usr/lib/jvm/java-8-oracle/include -c MainImpl1.c -o MainImpl1.o

In file included from MainImpl1.c:1:0:
/usr/lib/jvm/java-8-oracle/include/jni.h:45:20: fatal error: jni_md.h: No such file or directory
 #include "jni_md.h"
                ^
compilation terminated.

I have given example for generating .a file, but same issue observed for .so file generation also.

我已经给出了生成 .a 文件的示例,但对于 .so 文件生成也观察到了同样的问题。

But same gcccommand works for openjdk7/oraclejdk7.

但同样的gcc命令适用于 openjdk7/oraclejdk7。

What is the issue here?

这里有什么问题?

回答by Mathieu

I think that you do not added include directory that includes jni_md.hwhich is platform dependent.

我认为你不添加包括包括目录jni_md.h依赖于平台

Try

尝试

$gcc -I/usr/lib/jvm/java-8-openjdk-amd64/include -I/usr/lib/jvm/java-8-openjdk-amd64/include/linux -c MainImpl1.c -o MainImpl1.o

or

或者

$gcc -I/usr/lib/jvm/java-8-oracle/include -I/usr/lib/jvm/java-8-oracle/include/linux -c MainImpl1.c -o MainImpl1.o

If you don't know where jni_md.h is, use find:

如果您不知道 jni_md.h 在哪里,请使用find

find / -name jni_md.h 2> /dev/null