I'm slightly confused about klibs.. I have a klib ...
# kotlin-native
k
I'm slightly confused about klibs.. I have a klib created, its created fine via cinterop and installed via klib, has all the knms and all and is located in .konan/klib folder, but why am I unable to simply import it to a project? I was under the assumption that K/N is aware of klibs and where they're? Am I missing something here to be able just do import myPkg ?
a
What error are you getting? Is it a problem during compilation, or is it an IntelliJ error?
k
It's IntelliJ error and during compilation that it can't find the import (klib)
But if I build executable via kotlinc-native and pass -l of the klib it builds fine
a
Can you try running the Gradle task
copyCommonizeCInteropForIde
? I think it sets up autocomplete for IntelliJ by copying the klib into
$projectDir/.gradle/kotlin
k
Don't seem to have that task tbh. The way I've done it is that I've created the .klib separately with cinterop tool and installed via klib so I'm trying to find out how can I get kotlin native to actually pick it up and load it, which seems like copyCommonizeCInteropForIde is the task that could help, but I'm missing it
Are there some guides on how to even add .klib as dependencies?
Okay actually managed to get it working by passing:
Copy code
sourceSets {
    val nativeMain by getting {
        dependencies {
            implementation(fileTree("F:\\kaylibc\\kaylibc.klib"))
        }
    }
}
l
Are you able to set up a def file instead of manually building a klib?
k
I can and it works that way, however I'm kind of experimenting how far you can go with Kotlin Native without relaying on gradle
I have all working perfectly fine now