我一直试图使用cinterop向Kotlin/本机添加ncurses,但是这个错误显示:
Exception in thread "main" java.lang.Error: /usr/include/stdint.h:26:10: fatal error: 'bits/libc-header-start.h' file not found我检查并在此路径中安装了该文件。
这是我的密码:
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 -lncursesbuild.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
}
}发布于 2022-01-06 23:57:01
看起来您的包含过滤器可能太严格了。尝试将该头文件的父目录添加到您的cinterop文件中。在我的Ubuntu安装中,它在/usr/include/x86_64-linux-gnu中,但在您的compilerOpts中没有列出。
另一个注意事项-是否有理由在您的文件中列出两次-I/usr/include?
https://stackoverflow.com/questions/70613369
复制相似问题