JNIDemoJava Netbeans教程中未解析的包含

p3rjfoxz  于 2022-11-10  发布在  Java
关注(0)|答案(1)|浏览(156)

我的目标是完成开始netbeans java / c JNIDemo应用程序,可以在网站https://netbeans.apache.org/kb/docs/cnd/beginning-jni-linux.html上找到
我已经完成了大部分的步骤,但是在“实现一个方法”这一步我卡住了。JNIDemoCld. c文件的这个方法的代码如下。
下图显示了第1行上的黄色警告灯泡

当悬停在灯泡以下消息出现,我已经尝试,并试图谷歌和故障排除没有成功,它似乎是这个警告的来源是jni.h文件。
“库文件”“
但存在未解析的#include****
在包含的**/用户/包含/功能.h**中”
生成失败消息相当长。

cd '/home/jerryw/NetBeansProjects/JNIDemoCdl'
/usr/bin/gmake -f Makefile CONF=Debug
"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk QMAKE= 

SUBPROJECTS= .build-conf
    gmake[1]: Entering directory '/home/jerryw/NetBeansProjects/JNIDemoCdl'

"/usr/bin/gmake"  -f nbproject/Makefile-Debug.mk dist/libJNIDemoCdl.so
gmake[2]: Entering directory '/home/jerryw/NetBeansProjects/JNIDemoCdl'
mkdir -p build/Debug/GNU-Linux
rm -f "build/Debug/GNU-Linux/JNIDemo.o.d"
gcc -shared -m32   -c -g -I/usr/lib/jvm/java-1.8.0-openjdk-amd64/include -I/usr/lib/jvm/java-1.8.0-openjdk-amd64/include/linux -include /usr/lib/jvm/java-1.8.0-openjdk-amd64/include/classfile_constants.h -include /usr/lib/jvm/java-1.8.0-openjdk-amd64/include/jni.h -include /usr/lib/jvm/java-1.8.0-openjdk-amd64/include/jvmti.h -include /usr/lib/jvm/java-1.8.0-openjdk-amd64/include/jvmticmlr.h -include /usr/lib/jvm/java-1.8.0-openjdk-amd64/include/linux/jni_md.h -fPIC  -MMD -MP -MF "build/Debug/GNU-Linux/JNIDemo.o.d" -o build/Debug/GNU-Linux/JNIDemo.o JNIDemo.c
In file included from /usr/lib/jvm/java-1.8.0-openjdk-amd64/include/jni.h:39,
                 from <command-line>:32:
/usr/include/stdio.h:27:10: fatal error: bits/libc-header-start.h: No such file or directory
   27 | #include <bits/libc-header-start.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
gmake[2]:***[nbproject/Makefile-Debug.mk:68: build/Debug/GNU-Linux/JNIDemo.o] Error 1
gmake[2]: Leaving directory '/home/jerryw/NetBeansProjects/JNIDemoCdl'
gmake[1]:***[nbproject/Makefile-Debug.mk:59: .build-conf] Error 2
gmake[1]: Leaving directory '/home/jerryw/NetBeansProjects/JNIDemoCdl'
gmake:***[nbproject/Makefile-impl.mk:40: .build-impl] Error 2

构建失败(退出值2,总时间:74毫秒)
[3]运行一个微不足道的“Hello World”应用程序没有问题。
Re:[2]你能更具体地说明一下我在设置C/C++环境时做了些什么吗?我对此的解释是,我添加了include头和目录作为include和include/linux目录的位置。
然而,正如你所说的,因为这是一个很老的教程,它现在可能不会正常工作。
例如,我认为问题开始的地方是:

Setting Project Properties
Right-click the JNIDemoCdl project node and choose Properties.

In the Properties dialog box, select the C Compiler node under the Build properties.

***

Click the Include Directories and Headers …​ button and click Add in the Include Directories and Headers dialog box.

Browse into your JDK directory, and select the include subdirectory.

Select the Store path as Absolute option, then click Select to add this directory to the project’s Include Directories.

Add the JDK’s include/linux directory in the same way, then click OK.

在实际的C编译器中有两个目录项,而不是一个组合项...一行用于设置Include目录,下一行用于Include头。我将所有的头添加到Include头项中。这只是我对失败构建的来源的猜测。

kyxcudwk

kyxcudwk1#

感谢您发送编修。
1以下是我为解决此初始失败问题而采取的操作的摘要
尝试实作Java原生界面项目的方法实作
a a动态C/C++程式库。
构建失败主要集中在以下设置:

Build->C Compiler ->Additional Options->-shared -m32

编译器需要start.h信头的include信头,但它不在
包含库。我可能添加了错误的包含库,因为
非常旧的protocall与我所拥有的NetBeans版本不一致
已安装。
感谢@skomisa提供链接:
"fatal error: bits/libc-header-start.h: No such file or directory" while compiling HTK
在那里我找到了答案。
所以我用“sudo apt-get install gcc multilib”安装了gcc -multilib。
这为附加选项设置-m32添加了可用的头文件
设置.
之后,构建成功。

相关问题