I have been trying to add ncurses to Kotlin/Native using cinterop, but this error shows up:
Exception in thread "main" java.lang.Error: /usr/include/stdint.h:26:10: fatal error: 'bits/libc-header-start.h' file not found
I checked and I have this file installed in this path.
this is my code:
src/nativeInterop/cinterop:
headers = ncurses.h
headerFilter = ncurses.h
compilerOpts.linux = -I/usr/include -I/usr/include
linkerOpts.linux = -L/usr/lib64 -L/usr/lib/x86_64-linux-gnu -lncurses
build.gradle.kts
plugins {
kotlin("multiplatform") version "1.6.10"
}
group = "org.example"
version = "1.0-SNAPSHOT"
kotlin {
val hostOs = System.getProperty("os.name")
val isMingwX64 = hostOs.startsWith("Windows")
val nativeTarget = when {
hostOs == "Mac OS X" -> macosX64("native")
hostOs == "Linux" -> linuxX64("native")
isMingwX64 -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
nativeTarget.apply {
compilations["main"].cinterops {
val ncurses by creating {
when(preset) {
presets["linuxX64"] -> includeDirs.headerFilterOnly("/usr/include", "/usr/include/x86_64-linux-gnu")
}
}
}
binaries {
executable {
entryPoint = "main"
}
}
}
sourceSets {
val nativeMain by getting
val nativeTest by getting
}
}
CodePudding user response:
It looks like your include filter might be too strict. Try adding the parent directory of that header file to your cinterop file. On my Ubuntu install, it's in /usr/include/x86_64-linux-gnu, but that's not listed in your compilerOpts.
Another note -- is there a reason to have -I/usr/include listed twice in your file?
