cklib
cklib copied to clipboard
symbol multiply defined
Describe the bug
Building a iOS Project fails
error: Compilation failed: Linking globals named 'test_function': symbol multiply defined!
> Task :composeApp:linkDebugFrameworkIosSimulatorArm64 FAILED
warning: Cannot infer a bundle ID from packages of source files and exported dependencies, use the bundle name instead: ComposeApp. Please specify the bundle ID explicitly using the -Xbinary=bundleId=<id> compiler flag.
error: Compilation failed: Linking globals named 'test_function': symbol multiply defined!
* Source files:
* Compiler version: 1.9.22
* Output kind: FRAMEWORK
error: java.lang.Error: Linking globals named 'test_function': symbol multiply defined!
at org.jetbrains.kotlin.backend.konan.llvm.DefaultLlvmDiagnosticHandler.handle(diagnosticReport.kt:25)
at org.jetbrains.kotlin.backend.konan.llvm.LlvmDiagnosticCollector.flush(diagnostics.kt:36)
Affected platforms
- iOS
Versions
- Kotlin version*: 1.9.22
- Compose Multiplatform version*: 1.6.0
To Reproduce Steps and/or the code snippet to reproduce the behavior:
- Put this code into the
build.gradle.ktsfile
iosTarget.compilations {
val main by getting {
cinterops {
create("Samplecinterop") {
header(file("native/Samplecinterop/Samplecinterop.h"))
}
}
}
}
cklib {
config.kotlinVersion = libs.versions.kotlin.get()
create("Samplecinterop") {
language = co.touchlab.cklib.gradle.CompileToBitcode.Language.C
srcDirs = project.files(file("native/Samplecinterop"))
}
}
- Put this file into the
iosMainfolder
Test.kt
import Samplecinterop.test_function
import kotlinx.cinterop.ExperimentalForeignApi
class Test {
@OptIn(ExperimentalForeignApi::class)
fun testMethod() {
test_function()
}
}