cklib icon indicating copy to clipboard operation
cklib copied to clipboard

symbol multiply defined

Open wooram-yang opened this issue 1 year ago • 0 comments

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:

  1. Put this code into the build.gradle.kts file
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"))
    }
}
  1. Put this file into the iosMain folder
Test.kt

import Samplecinterop.test_function
import kotlinx.cinterop.ExperimentalForeignApi

class Test {
@OptIn(ExperimentalForeignApi::class)
	fun testMethod() {
		test_function()
	}
}

testcinterop.zip

wooram-yang avatar Mar 23 '24 16:03 wooram-yang