Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use client library for macos arm 64 #18

Closed
alkurop opened this issue Jul 24, 2023 · 4 comments
Closed

Can't use client library for macos arm 64 #18

alkurop opened this issue Jul 24, 2023 · 4 comments

Comments

@alkurop
Copy link

alkurop commented Jul 24, 2023

I cloned the repo and published common and client to maven local.

My project script is just one file

    kotlin("multiplatform") version "1.9.0"
}

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

repositories {
    mavenCentral()
    mavenLocal()
}

kotlin {
    macosArm64("macos") {
        binaries {
            executable {
                entryPoint = "main"
            }
        }
    }

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("com.github.davidepianca98:kmqtt-client:0.4.1")
                implementation("com.github.davidepianca98:kmqtt-common:0.4.1")
            }
        }
        val macosMain by getting {
            dependencies {
                implementation("com.github.davidepianca98:kmqtt-common-macosarm64:0.4.1")
                implementation("com.github.davidepianca98:kmqtt-client-macosarm64:0.4.1")
            }
        }
    }
}

I have my main function in src/commonMain/kotlin/Main

Intellij indexer shows that I can import the MQTT library. Project compilation fails with
e: Could not find "openssl-macos-arm64" in [projectDir, /Users/alex/.konan/klib, /Users/alex/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.0/klib/common, /Users/alex/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.0/klib/platform/macos_arm64]

  1. Is my set up correct?
  2. what's the issue with open ssl? What to do here?
  3. I also want to build for an other target linuxarm64 (Raspberry Pi). Is this project compatable?
@davidepianca98
Copy link
Owner

davidepianca98 commented Jul 25, 2023

Hello, as you can see the file that could not be found is here https://github.com/davidepianca98/KMQTT/tree/master/kmqtt-common/src/nativeInterop and is bundled with the dependencies you included. I suggest trying to invert the lines so that common is before client in the commonMain section.
Also I suggest removing the dependecies of the macosMain section as they get automatically included.

sourceSets {
    val commonMain by getting {
        dependencies {
            implementation("com.github.davidepianca98:kmqtt-common:0.4.1")
            implementation("com.github.davidepianca98:kmqtt-client:0.4.1")
        }
    }
}

Let me know if this works.

Yes the project is compatible also with linuxArm64, you just need to include the target in the kotiln section.

@alkurop
Copy link
Author

alkurop commented Jul 25, 2023

With recommended set up

Screenshot 2023-07-25 at 14 26 25

still have error e: Could not find "openssl-macos-arm64"

It only works when I move the libs to home/.konan/klib

Screenshot 2023-07-25 at 14 10 13

At this point my final script is:

Screenshot 2023-07-25 at 14 45 39

but library only imports from .konan/klibfolder
Is there a way to avoid, and import library from a project folder?

PS: I see that openssl.def has local paths from your machine.

@alkurop alkurop closed this as completed Jul 25, 2023
@alkurop alkurop reopened this Jul 25, 2023
@davidepianca98
Copy link
Owner

Your final script is correct. Unfortunately the problem is that with Apple targets the openssl klib doesn't get included in the dependency package, as mentioned in #17. I still haven't found a solution for that.

@alkurop
Copy link
Author

alkurop commented Jul 25, 2023

hm, actually I looked once again at the error e: Could not find "openssl-macos-arm64" in [projectDir, /Users/alex/.konan/klib, /Users/alex/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.0/klib/common, /Users/alex/.konan/kotlin-native-prebuilt-macos-aarch64-1.9.0/klib/platform/macos_arm64] ;
The first place it looks for the is projectDir (the actual name is replaced).

Once I placed the libraries into the root dir It started working, without need to mention open-ssl in the script. Safely removed library from .konan, cleaned project and it still works.

Until there's a way to place libs into a folder, keeping them in project dir.
Screenshot 2023-07-25 at 18 29 31

Maybe this method will help to resolve the iOS issue too?

@alkurop alkurop closed this as completed Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants