I have a build.gradle file which I'm trying to use it to build my JNI instance with, I have been using the Gradle documentation but there are a lot of C++ examples and not many with C. What I'm trying to achieve is a setup where I can add any number of .c and .h files into my application and use Gradle to compile these and create one or multiple .so library file(s).
I know my build.gradle is wrong but I'm lost for ideas how to go about this, I've found lots of stuff on the C++ side of JNI but not C.
My current Project structure looks like this:
project/
├──src/
└── com/
└── example/
└── subProjectExample1
└── HelloJNI.java
└── subProjectExample2
└── main.java
└── main/
├── c
└── HelloJNI.c
├── headers
└── com.example_HelloJNI.h
build.gradle
allprojects {
apply plugin "java"
apply plugin "c"
apply plugin "eclipse"
}
subprojects {
apply plugin "java"
repositories {
jcenter()
}
}
project(':example1') {
dependencies {
}
}
project(':example2') {
dependencies {
compile project(':example1')
}
}
model {
repositories {
libs(PrebuiltLibraries) {
jdk {
headers.srcDirs "${System.properties['java.home']}/../include",
"${System.properties['java.home']}/../include/linux"
}
}
}
platforms {
linux64 {
operatingSystem "linux"
architecture "x86_64"
}
}
toolchains {
gcc(Gcc) {
eachPlatform {
cCompiler.executable = "/usr/bin/gcc"
}
}
}
components {
main(NativeLibrarySpec) {
sources {
c {
source {
srcDir "src/main/c"
include "**/*.c"
}
exportedHeaders {
srcDir "src/main/headers"
}
}
}
}
}
}
I'm running this with the ./gradlew mainExecutable
from these documents
The output.txt I'm getting is:
HelloJNI.c: fatal error: jni.h: No such file or directory
#include "jni.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1
Just for reference I'm using Gradle version 5.6.2 with Eclipse.
EDIT:
I have added the following:
repositories {
libs(PrebuiltLibraries) {
jdk {
headers.srcDirs "${System.properties['java.home']}/../include",
"${System.properties['java.home']}/../include/linux"
}
}
}
But I'm still getting the same error.