While executing gcc
command on ubuntu for generating .a or .so file for JNI, getting below error for both openjdk 8 / oraclejdk8.
在ubuntu中执行gcc命令生成一个或。
$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.
我已经给出了生成一个文件的例子,但是同样的问题也被观察到了。
But same gcc
command works for openjdk7/oraclejdk7.
但是,同样的gcc命令也适用于openjdk7/oraclejdk7。
What is the issue here?
这里的问题是什么?
1 个解决方案
#1
6
I think that you do not added include directory that includes jni_md.h
which 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 / -name jni_md.h 2> /dev/null
#1
6
I think that you do not added include directory that includes jni_md.h
which 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 / -name jni_md.h 2> /dev/null