Piasy
01/07/2023, 8:51 AMkotlin {
linuxX64 {
compilations.main {
cinterops {
xlog {
defFile "src/cppCommon/cinterop/xlog.def"
includeDirs {
allHeaders "${project.projectDir}/src/cppCommon/cpp"
}
}
}
kotlinOptions.freeCompilerArgs += [
"-include-binary",
"${project.projectDir}/src/linuxMain/libs/x64/libkmp_xlog.a".toString()
]
}
}
}
The key point is setting kotlinOptions.freeCompilerArgs
.
I’m wondering another thing: my c++ code depends on pthread
and z
, so in module which produces executable, my lib users need to add these two linker flags,
kotlin {
linuxX64 {
binaries {
all {
linkerOpts = [
"-lpthread",
"-lz",
]
}
executable("kmp_xlog") {
entryPoint = "com.piasy.kmp.xlog.example.main"
}
}
}
}
Is it possible that I specify these two linker flags in my library module, so they can be added to dependent modules automatically? So my lib users only need to add a gradle dependency, no need to set linkerOpts.vbsteven
01/07/2023, 9:08 AMPiasy
01/07/2023, 9:08 AMvbsteven
01/07/2023, 9:09 AMPiasy
01/07/2023, 9:15 AM