未知类型名称“ WINBOOL”

时间:2019-09-09 09:07:54

标签: windows kotlin-native

我正在尝试将psapi链接到Kotlin本机应用程序,但是遇到了我不知道如何解决的错误。

按错误类型看,我似乎在链接器选项中缺少某些内容,但找不到任何有关它的信息。

build.gradle.kts:

plugins {
    kotlin("multiplatform") version "1.3.50"
}

repositories {
    mavenCentral()
}

kotlin {
    mingwX64("HelloWorld") {
        val main by compilations.getting
        val psapi by main.cinterops.creating

        binaries {
            executable("HelloWorldApp") {
                entryPoint = "sample.helloworld.main"
            }
        }
    }
}

src / nativeInterop / cinterop / psapi.def:

headers = psapi.h
headerFilter = psapi/*

linkerOpts.mingw = -lpsapi

实际的异常消息:

Exception in thread "main" java.lang.Error: C:\Users\pawer\.konan\dependencies\msys2-mingw-w64-x86_64-gcc-7.3.0-clang-llvm-lld-6.0.1-2\x86_64-w64-mingw32\include\psapi.h:75:3: error: unknown type name 'WINBOOL'
    at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:146)
    at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.indexDeclarations(Indexer.kt:963)
    at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.buildNativeIndexImpl(Indexer.kt:952)
    at org.jetbrains.kotlin.native.interop.indexer.NativeIndexKt.buildNativeIndex(NativeIndex.kt:91)
    at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:222)
    at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:38)
    at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:69)
    at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:18)

FAILURE: Build failed with an exception.

1 个答案:

答案 0 :(得分:2)

问题解决了

src / nativeInterop / cinterop / psapi.def:

headers = windows.h \ psapi.h
headerFilter = psapi.h
package = psapi

linkerOpts.mingw = -lpsapi