Hey, why does the cinterop gradle task in an mpp p...
# kotlin-native
Hey, why does the cinterop gradle task in an mpp project require the static lib file to exist to run successfully? I thought that task just used headers to generate kotlin bindings, does it use the lib in some way? Also, what task is actually responsible for creating the klib? I'm trying to make a MPP project that has tasks to build a cmake project as a static lib and then I'd like to include that lib after it's been made. Anyone know how I might a) prevent cinterop from failing from the not yet built static lib and b) include a static lib in the generated klib.
I was able to work this out. cinterop IS creating a klib, and then your MPP project itself is a different klib that imports the cinterop klib. Instead of listing the static lib in a cinterop def, you can include the static library in your MPP project klib with
Copy code
kotlin {

    targets.withType<KotlinNativeTarget> {
         kotlinsOptions {
             freeCompilerArgs = listof("-include-binary", dirToStaticLib)
, then any project including this as a dependency will statically link to that library. This way cinterop doesn't choke on the missing lib, and you can add tasks to your project to build your cmake lib. Note, those tasks should depend on the processResourcesTaskName of your compilations.