我正在尝试遵循本教程https://gist.github.com/DmitrySoshnikov/8b1599a5197b5469c8cc07025f600fdb来简单地从mac上的Java调用一个c文件。我已经成功地构建并编译了我的JNIExample.java。我还制作了JNIExample.h文件。但是当我执行第五步:gcc -I"$JAVA_HOME/include" -I"$JAVA_HOME/include/darwin/" -o libjniexample.jnilib -shared JNIExample.c时,我收到了这个错误:
JNIExample.c:2:10: fatal error: 'jni.h' file not found
#include <jni.h>
^~~~~~~
1 error generated.您知道如何生成此文件并解决此错误吗?
我的环境是mac,我的文件夹中有以下文件:
(base) MacBook-Pro-7:JNI-C++ Home$ ls
JNIExample.c JNIExample.h
JNIExample.class JNIExample.java发布于 2020-08-12 02:33:41
包含在$JAVA_HOME/ jni.h中。
但它也会失败,因为jni.h为_m_achine-_d_ependent特性引用了jni_md.h。因此,您必须将$JAVA_HOME/ include /(linux|win32)添加到包含路径。(我不确定是不是MacOS)
https://stackoverflow.com/questions/63362796
复制相似问题