My goal is to complete the beginning netbeans java / c JNIDemo application that can be found at the website https://netbeans.apache.org/kb/docs/cnd/beginning-jni-linux.html
I have completed the majority of the steps to do this however I am stuck at the "Implementing a Method" step. The code for this method of the JNIDemoCld.c file follows.
The following image shows the yellow warning lightbulb on line 1
When hovering over the lightbulb the following message appears which I have tried and tried to google and troubleshoot without success, it appears that the source of this warning is the jni.h file.
"Library File /usr/lib/jvm/java-1.8.0-openjdk-amd64/include/jni.h
but there is an unresolved #include <sys/cdefs.h>
in included /user/include/features.h"
The build failed message is rather lengthy.
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
BUILD FAILED (exit value 2, total time: 74ms)
[3] No problem with running a trivial "Hello World" application.
Re:[2] Could you be a little more specific as to what I did setting up the C/C++ environment? My interpretation of this is that I added include headers and directories as the location of the include and include/linux directories.
However,Re:[4] as you said, because this is such an old tutorial, it probably won't work properly now anyway.
For example, here is the part where I think the problem started:
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.
There are two entries in the actual C compiler look in directories instead of one combined ...One line is for setting the Include directory and the next line is for Include Headers. I added all of the headers to the Include headers entry. This is only my guess as to the source of the failed build.