Writing my first ever KotlinNative test applicatio...
# kotlin-native
v
Writing my first ever KotlinNative test application, following the instructions at https://play.kotlinlang.org/hands-on/Introduction%20to%20Kotlin%20Native/04_AddingInteropToBuild . Not going well as gradle is not recognising compilations.main ('main' is in red). Full source is:
Copy code
linuxArm32Hfp("pi") {
        compilations.main {
           cinterops {
               libcurl
           }
        }
        binaries {
            executable {
                entryPoint = "main"
            }
        }
    }
k
you can do
compilations { "main" { ...
b
have you tried
Copy code
compilations {
  named("main") {}
}
k
also works
b
Wasn't aware @Kris Wong way is an option. That's probably the cleanest solution.
v
Well, that's progress - libcurl still not found. I've got libcurl.def in src/nativeInterop/cinterop .
k
yeah it's somewhat unusual syntax. but somehow it works.
b
Ah, got that one myself. Gimmie a sec to find an example
k
you need to add the path to the linker flags
v
Worries me that the tutorial from the documentation is wrong in several ways!
k
you can do it in the def file or the gradle file. I find the gradle file is more appropriate
i put all paths in the gradle file
b
The example above handles it for all native platforms.
I found that hard-coding the paths breaks on win/linux (works on one, fails on the other)
k
Copy code
iosX64("ios") {
        compilations {
            "test" {
                cinterops.create("OHHTTPStubs") {
                    includeDirs("c_interop/OHHTTPStubs/Headers")
                }
            }
        }
        binaries.getTest(DEBUG).linkerOpts("-Lc_interop/OHHTTPStubs")
    }
in the def file,
linkerOpts = -lOHHTTPStubs -ObjC
v
So nothing at all like the tutorials or instructions then 🙂
b
Kotlin Native is wild wild west
k
that's an understatement 🙂
😄 1
v
Also, very mac/iOS focused, which holds no interest for me. I'm all about the Raspberry Pi.
b
Indeed. I think most of the JB devs are on MACs and also android being the main driver for kotlin these days explains why IOS is a focus to promote KMM
It's just the good old supply/demand
v
I'm just hoping I can avoid writing in Python on the Pi. Or C, but I haven't written any C for 20 years.
b
Once you nail down the initial setup K/N is a blast to work with (unless you decide to throw in multithreading into the mix, in which case hold on to your hat!)
v
Lovely error here...
Cause: cannot assign instance of java.lang.StackTraceElement to field java.lang.StackTraceElement.moduleVersion of type java.lang.String in instance of java.lang.StackTraceElement
but I will work it out!
b
Lol, never seen stack trace to fail to write itself 😄
k
concurrency is a hot mess. avoid it if possible
b
Just to be clear, concurrency is fine as long as you do it on a single thread. Parallelizm cases issues due to unique K/N memory model
v
I think I am very far away from worrying about concurrency. Now, if only IntelliJ ran on the Pi...