sqldelight icon indicating copy to clipboard operation
sqldelight copied to clipboard

Compilation fails on Mac M1 for target linux_arm64

Open alkurop opened this issue 6 months ago • 0 comments

SQLDelight Version

2.0.2

Operating System

Mac arm64

Gradle Version

8.8

Kotlin Version

1.9.0

Dialect

SQLite

AGP Version

No response

Describe the Bug

Compilation fails for target linux_arm64. Compiler cannot find library sqlite3 and fails with exception:

I understand that I need to include sources for sqlite. I have a few questsions:

  1. can I include a pre-build sqlite3.klib somehow?
  2. can I instead provide a static library libsqlite3.a with a def file?
  3. is there an other option, maybe build this library on my linux arm system? I cannot complie the whole project there because it's a Raspberri Pi.

Many thanx

Stacktrace

> Task :linkDebugExecutableLinuxArm64 FAILED
e: /Users/alex/.konan/dependencies/apple-llvm-20200714-macos-aarch64-essentials/bin/ld.lld invocation reported errors

The /Users/alex/.konan/dependencies/apple-llvm-20200714-macos-aarch64-essentials/bin/ld.lld command returned non-zero exit code: 1.
output:
ld.lld: error: unable to find library -lsqlite3


### Gradle Build Script

```gradle
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.konan.target.HostManager

plugins {
    kotlin("multiplatform") version "1.9.0"
    kotlin("plugin.serialization") version "1.9.0"
    id("app.cash.sqldelight") version "2.0.2"
}

group = "me.alex"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
    mavenLocal()
}

sqldelight {
    databases {
        create("Database") {
            packageName.set("connection.schema")
            srcDirs.setFrom("src/commonMain/kotlin")
        }
    }
}

kotlin {

    jvm {}
    listOf(macosArm64 {}, linuxArm64 {})
        .map { it.binaries { executable { entryPoint = "main" } } }

    sourceSets {

        val commonMain by getting {

            dependencies {
                implementation("com.github.davidepianca98:kmqtt-common:0.4.1")
                implementation("com.github.davidepianca98:kmqtt-client:0.4.1")
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")

                //https://github.com/irgaly/kottage
                //https://kotlinlang.org/docs/multiplatform-mobile-concurrency-and-coroutines.html#multithreaded-coroutines
                implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1")

            }
        }
        val macosArm64Main by getting  {
            dependencies{
                implementation("app.cash.sqldelight:native-driver:2.0.2")
            }
        }
        val linuxArm64Main by getting  {
            dependencies{
                implementation("app.cash.sqldelight:native-driver:2.0.2")
            }
        }
        val jvmMain by getting  {
            dependencies{
                implementation("app.cash.sqldelight:sqlite-driver:2.0.2")
            }
        }
        val jvmTest by getting {
            dependencies {
                implementation(kotlin("test-annotations-common"))
                implementation(kotlin("test"))
                implementation(kotlin("test-junit"))
            }
        }
    }
}

alkurop avatar Jul 30 '24 19:07 alkurop