jni.h:没有这样的文件或目录Netbeans IDE
fatal error: jni.h: No such file or directory Netbeans IDE
我想学习如何从c++调用java函数,经过一些链接后,我知道我们需要在c++文件中添加以下头文件
#include <jni.h>
但是当我在Netbeans IDE中的c++文件中添加此文件时,我得到了以下错误
fatal error: jni.h: No such file or directory
如何删除这个错误,我只是初学者在JNI。
我浏览了之前在stackoverflow上问过的问题,但没能浏览这个问题。
下面是我的编译输出:
"/C/MinGW/MSYS/1.0/bin./make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/c/Users/Simer/Documents/NetBeansProjects/JniDemo'
"/C/MinGW/MSYS/1.0/bin./make.exe" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/jnidemo.exe
make.exe[2]: Entering directory `/c/Users/Simer/Documents/NetBeansProjects/JniDemo'
mkdir -p build/Debug/MinGW-Windows
rm -f "build/Debug/MinGW-Windows/main.o.d"
g++ -c -g -MMD -MP -MF "build/Debug/MinGW-Windows/main.o.d" -o build/Debug/MinGW-Windows/main.o main.cpp
main.cpp:9:17: fatal error: jni.h: No such file or directory
#include <jni.h>
^
compilation terminated.
make.exe[2]: *** [build/Debug/MinGW-Windows/main.o] Error 1
make.exe[2]: Leaving directory `/c/Users/Simer/Documents/NetBeansProjects/JniDemo'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory `/c/Users/Simer/Documents/NetBeansProjects/JniDemo'
make.exe": *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 2s)
你正在编译没有包含Java头文件的MinGW,这就是为什么它抱怨没有找到
尝试将此选项添加到编译命令-I"c:/path/to/jdk/include" -I"c:/path/to/jdk/include/win32" -D__int64="long long"
中。
最后一个选项是为了避免由于windows编译器使用__int64类型而gcc使用long long而导致的错误。
你看过Netbeans JNI教程吗?
它非常详细地介绍了你应该做的所有事情。
相关文章:
- 为什么联机C++ IDE 不支持"graphics.h"头文件?
- MSBuild 由于缺少属性文件(可能与 IDE 相关)而无法生成 Visual Studio 项目
- 无法在代码块 IDE 中打开输出文件.exe
- Arduino IDE中自定义库类的.h文件编译错误的原因是什么
- 有什么理由更喜欢从 IDE 中运行应用程序而不是运行独立的可执行文件?
- Eclipse IDE for C/C++:找不到二进制文件,修复混乱
- GitHub开源文件到不同的IDE
- 使用由不同 IDE 生成的库文件
- CLion IDE在哪里查找头文件
- IDE 如何创建可执行文件
- 为什么现代C++ IDE 不能自动生成头文件
- 通过终端和编译创建项目文件失败,但通过Qt Creator IDE工作正常
- 程序从IDE运行时找不到映像目录,但从文件夹运行时却找不到CAN
- 使用大型源代码文件的IDE建议
- 如何使用不同的ide在不同的目录中包含文件
- Arduino IDE不识别.c文件是.cpp
- 努力将我的c++项目作为单个可执行文件从Eclipse IDE发布
- 如何将web服务器上公共目录中的C++文件直接包含到IDE中
- Exe二进制文件只在IDE外部崩溃
- jni.h:没有这样的文件或目录Netbeans IDE