https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
kotlin-native
  • s

    spierce7

    08/28/2021, 6:19 AM
    Another question - How do I add a dylib library to my compiled executable?
    • 1
    • 1
  • h

    Hsiao Mui

    08/29/2021, 8:32 AM
    Hi Everyone, I am trying work with inotify on linux ( https://man7.org/linux/man-pages/man7/inotify.7.html ) it appears that Kotlin Native (1.5.10) C interop does support the inotify header, but  the helper class mapping
    inotify_event
     struct does not have any of it’s members. Has anyone encountered this issue before ?
    ➕ 2
    m
    m
    n
    • 4
    • 5
  • s

    Sterling Albury

    08/30/2021, 12:51 AM
    hey all, I’m trying to add a new hardware target for konan, so I put the new target description in 
    .konan/platforms/zephyr
     and rebuilt the compiler but I’m not seeing it show up in
    konanc -list-targets
    . I should be seeing it show up with
    -list-targets
    , no? I’m not seeing the
    stm32f4_disco
    target show up either. when I try to compile a program for my target or the
    stm32f4_disco
    target I get this error:
    » konanc hello.kt -target zephyr_stm32f4_disco                                                                                                                               
    error: compilation failed: Target zephyr_stm32f4_disco is not available on the macos_x64 host
    
     * Source files: hello.kt
     * Compiler version info: Konan: 1.6.0-dev / Kotlin: 1.6.255
     * Output kind: PROGRAM
    
    exception: java.lang.IllegalStateException: Target zephyr_stm32f4_disco is not available on the macos_x64 host
    	at org.jetbrains.kotlin.backend.konan.KonanConfig.<init>(KonanConfig.kt:95)
    	at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:79)
        ...
    I’ve been able to build and flash zephyr for my target boards. can I not build my kotlin program for these targets on a mac?
    n
    • 2
    • 5
  • s

    spierce7

    08/30/2021, 6:22 AM
    I’m building an executable that runs on MacOS. I’m using a dynamic library and no matter what I do, it’s looking for that library at
    /usr/local/lib/
    1. How do I tell get the dynamic library to load a file in a relative path to the
    .kexe
    executable? 2. If #1 isn’t possible, is it possible to embed a dynamic library into the
    .kexe
    ?
    a
    • 2
    • 11
  • a

    atsushieno

    08/30/2021, 10:31 AM
    Anyone experienced this sort of "gradle sync issues" that occurs on IDEA but not with gradlew (directly) ? https://gist.github.com/atsushieno/d614c3ac8bb85bea3d035ce4577fa32e
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':commonizeNativeDistribution'.
    Caused by: java.lang.ClassCastException: class org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension_Decorated cannot be cast to class org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension (org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension_Decorated is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @34f47f71; org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @3b0ff146)
    l
    • 2
    • 9
  • s

    spierce7

    08/31/2021, 3:03 PM
    I don’t fully understand why c functions have a free method for every single struct type. Wouldn’t a general purpose
    free
    method work, or heck, just using the C free method itself.
    m
    • 2
    • 6
  • s

    smallshen

    08/31/2021, 8:46 PM
    does anyone know why skiko support c++ in the interop https://github.com/JetBrains/skiko/blob/master/skiko/src/nativeInterop/cinterop/skia.def#L2
    🤔 2
    s
    • 2
    • 1
  • k

    kenkyee

    09/01/2021, 2:39 AM
    It didn't sound like it was mobile only...
    ➕ 2
    n
    • 2
    • 3
  • l

    Lars Toft Jacobsen

    09/01/2021, 3:43 PM
    Hi there, not sure if this is for mp, ios or this channel, so please bear with me: stuck on a issue where I have added a native IOS target to an existing mp multi-module project. Simply added this to gradle.build:
    iosX64("ios") {
        binaries {
            framework()
        }
    }
    plus sourcesets, and implemented a few expected types. All compilation tasks run successfully but the
    linkReleaseFrameworkIos
    always fails with a Java assertion error somewhere in the native compiler with zero hints to actual cause. Link debug framework succeeds for iosX64 but will likewise also fail for iosArm64. I deliberately chose one of the stand-alone modules as to not also deal with dependency issues. Any pointer to how I should approach this problem is greatly appreciated 🙏 Searching the docs didn’t yield much in terms of debugging compilations issues. Thanks.
    k
    • 2
    • 1
  • t

    Trevor Stone

    09/01/2021, 5:30 PM
    With the new official support for xcframeworks the
    assembleReleaseXCFramework
    task does not contain the dSYMs for the project from what I can tell. I, maybe ignorantly, thought these were important for crash reporting tools. Is there a reason it is only generated for the debug xcframeworks?
    s
    n
    • 3
    • 4
  • i

    Ink

    09/02/2021, 9:37 AM
    fun findName(personList: PersonList) : String?{
        var name: String? = null
        personList.person.forEach {
            name =  it.name
        }
        return name
    }
    Can I simplify that code?
    k
    • 2
    • 1
  • e

    Eryk Lepszy

    09/02/2021, 4:09 PM
    I'm writing an application for Linux and Windows hosts. It has to process files and directories that can often contain various japanese, korean, etc. UTF-8 characters in their names. Everything works fine on Linux, however on Windows they are never processed or displayed correctly, what leads to incorrect and broken paths.
    toKString()
    function returns correct values on Linux, and broken ones on Windows, I'm assuming because of some Windows or mingw encoding-related caveat that I can't figure out. I created a simple project to demonstrate the issue, does anyone know how to deal with this? https://gitlab.com/Chazoshtare/encoding-issue-kn/-/tree/master
    e
    n
    • 3
    • 4
  • a

    Alexander Black

    09/02/2021, 6:28 PM
    For some reason, in IntelliJ, my debugger does not stop on breakpoints when running common tests on iOS. Is there a trick to this? I kinda thought it would work out of the box. Any advice or resources would be greatly appreciated.
    t
    l
    • 3
    • 20
  • p

    Paul Woitaschek

    09/03/2021, 9:59 AM
    Is there an ETA for the new memory model? I don't expect a real date but rather a "not before february 2022" or alike
    👍 1
    s
    • 2
    • 1
  • r

    Raed Ghazal

    09/03/2021, 1:24 PM
    Hey guys I'm checking if mutli global variables are not null before calling a function like that
    varX?.let { varX ->
        varY?.let { varY ->
            foo(varX, varY)
        }
    }
    is there a better way to have this null safe and thread safe but in a cleaner look?
    e
    t
    +3
    • 6
    • 17
  • t

    Thomas

    09/03/2021, 9:10 PM
    After upgrading to Kotlin 1.5.30 I am running into a build failure for watchOS:
    clang (LLVM option parsing): for the --fast-isel option: may only occur zero or one times!
    clang (LLVM option parsing): for the --global-isel option: may only occur zero or one times!
    See full stack trace in thread. Any idea what the issue could be?
    s
    • 2
    • 3
  • s

    spierce7

    09/03/2021, 11:31 PM
    Does anyone know how to use a
    CPointerVar
    ? I’ve been stuck on this for a few days. I’m interacting with the following c function:
    idevice_error_t idevice_get_device_list_extended(idevice_info_t **devices, int *count);
    I’m calling it like this:
    val connectedDevices: CPointerVar<idevice_info_tVar> = alloc()
    val connectedDevicesSize: IntVar = alloc()
    idevice_get_device_list_extended(connectedDevices.ptr, connectedDevicesSize.ptr)
    I have no idea to get the array of devices out of the
    val connectedDevices
    . There are no examples using
    CPointerVar
    and
    CValues
    that I’ve been able to find to figure this out. Any help would be much appreciated!
    m
    • 2
    • 2
  • k

    Karlo Lozovina

    09/05/2021, 6:09 PM
    what's the quickest/easiest way to do some IPC with Kotlin/Native on Linux? Both processes in Kotlin, of course...
    m
    n
    • 3
    • 8
  • r

    Raed Ghazal

    09/06/2021, 3:10 PM
    Hey guys, just sharing a cool extension
    inline fun <T> massAction(vararg objects: T, block: T.() -> Unit) {
    objects.forEach {
    block(it)
    }
    }
    • 1
    • 1
  • w

    wmontwe

    09/07/2021, 1:19 PM
    Hi, who could help with slow compilation targeting iOS? Is Kotlin Native just slow when it reached a certain project size? We increased memory and applied all suggestions from the official https://kotlinlang.org/docs/native-improving-compilation-time.html suggestions. But no luck -> zero improvements. We’re now hitting over 50 minutes compile time and that’s a killer for our project. We see most time spend linking iosArm64 and iosX86. While linking CPU limits to only one core with memory consumption of 8GB and clang with peaks at 9 GB. We’re using Kotlin Native as part of a Kotlin Multiplatform project for 1,5 years now. It wasn’t great before but recently upgraded to Kotlin 1.5, Xcode 12.5.1 and Android Studio Arctic Fox and now it’s just painfully slow.
    😮 1
    c
    k
    +2
    • 5
    • 13
  • a

    ankushg

    09/07/2021, 5:31 PM
    Hey friends! We're rapidly increasing the amount of features that expose coroutines/flows to iOS, so our manual wrapping approach (while definitely easier thanks to @russhwolf’s abstractions) isn't exactly sustainable for the long-haul. Curious if anyone has worked with either of these (or any other) options for automating coroutine/flow wrapping for iOS: • Koru or • KMP-NativeCoroutines From the looks of it, Koru requires manual opt-in for each class via an annotation, and generates a new class for iOS that wraps the actual Kotlin implementation. KMP-NativeCoroutines automatically generates wrapped versions of suspend/Flow properties/functions in the same classes. It also provides its own helper pods to map to RxSwift, Combine, and Async/Await. Has anyone used both and have a strong preference for one vs the other? Are there any other substantial differences between the two? Should we just wait until KSP supports multiplatform?
    k
    f
    m
    • 4
    • 7
  • s

    Slackbot

    09/07/2021, 5:51 PM
    This message was deleted.
    p
    • 2
    • 2
  • b

    Big Chungus

    09/07/2021, 6:09 PM
    How do I write to file in ios or tvos tests? Is it even possible? Would posix APIs for that still work like on macos target?
    m
    • 2
    • 9
  • n

    napperley

    09/07/2021, 8:58 PM
    It appears as though the cinterop tool isn't generating the bindings relating to
    GtkStatusIcon
    ( https://stackoverflow.com/questions/41917903/gtk-3-statusicon-replacement ). Apparently
    GtkStatusIcon
    is accessible in the Gtk 3 API (there should be
    GtkStatusIcon
    declarations in the gtk/gtk.h header file), but has been removed in the Gtk 4 API. What Kotlin Native options are available for dealing with deprecated APIs in C libraries?
    • 1
    • 1
  • m

    Miroslav Sobotka

    09/07/2021, 10:42 PM
    Does anyone know how to get rid of these errors? 🤔
    The /home/mira/.konan/dependencies/x86_64-unknown-linux-gnu-gcc-8.3.0-glibc-2.19-kernel-4.9-2/x86_64-unknown-linux-gnu/bin/ld.gold command returned non-zero exit code: 1.
    output:
    /usr/lib64/libpipewire-0.3.so: error: undefined reference to 'fcntl64', version 'GLIBC_2.28'
    /usr/lib64/libpipewire-0.3.so: error: undefined reference to 'memfd_create', version 'GLIBC_2.27'
    /usr/lib64/libpipewire-0.3.so: error: undefined reference to 'stat64', version 'GLIBC_2.33'
    /usr/lib64/libpipewire-0.3.so: error: undefined reference to 'getrandom', version 'GLIBC_2.25'
    /usr/lib64/libpipewire-0.3.so: error: undefined reference to 'fstat64', version 'GLIBC_2.33'
    n
    • 2
    • 7
  • k

    Kweku

    09/08/2021, 1:02 PM
    Ny previously running ios app is now running into a build error on the linkPodDebugFrameworkIos/linkDebugFrameworkIos task. It just says Compilation Failed: Assertion Error, with error being MethodbridgeKt.parameterAssociated. StackTrace in comments
    a
    d
    • 3
    • 9
  • n

    napperley

    09/08/2021, 11:47 PM
    How does Kotlin Native handle C unions via C Interop? GdkEvent ( https://gnome.pages.gitlab.gnome.org/gtk/gdk3/union.Event.html ) is an example of a C Union. Using the
    gtk_menu_popup_at_pointer
    function ( https://docs.gtk.org/gtk3/method.Menu.popup_at_pointer.html ) as an example how would one pass through a "fake" Union to the function?
    c
    • 2
    • 2
  • s

    spierce7

    09/09/2021, 4:23 PM
    Is it possible to compile Kotlin x86 binaries on a Mac m1 laptop?
    :yes: 3
    a
    • 2
    • 1
  • s

    serebit

    09/11/2021, 11:59 PM
    Is toCStringArray supposed to segfault when it's run on an empty array?
    🇳🇴 2
    d
    • 2
    • 1
  • n

    napperley

    09/12/2021, 3:36 AM
    There are some weird warnings coming from the linker in relation to modules and target triples:
    > Task :linkTodoDebugExecutableLinuxArm32
    w: Linking two modules of different target triples: /tmp/native13265186009735942822/cstubs.bc' is 'armv6-unknown-linux-gnueabihf' whereas 'out' is 'armv6kz-unknown-linux-gnueabihf'
    
    w: Linking two modules of different target triples: /tmp/native627338979534854439/cstubs.bc' is 'armv6-unknown-linux-gnueabihf' whereas 'out' is 'armv6kz-unknown-linux-gnueabihf'
    
    w: Linking two modules of different target triples: /tmp/native7458931769986923423/cstubs.bc' is 'armv6-unknown-linux-gnueabihf' whereas 'out' is 'armv6kz-unknown-linux-gnueabihf'
    What do the warnings mean? It is important to note that the Linux ARM HFP 32 binary is created successfully. These warnings are confusing since the linuxArm32Hfp target is used, which is based on Linux ARMv7, not Linux ARMv6. The warnings above do not occur if Kotlin 1.5.20 is used instead of Kotlin 1.5.30. Looks like there is a major issue with linking for the linuxArm32Hfp target in Kotlin 1.5.30.
    • 1
    • 1
Powered by Linen
Title
n

napperley

09/12/2021, 3:36 AM
There are some weird warnings coming from the linker in relation to modules and target triples:
> Task :linkTodoDebugExecutableLinuxArm32
w: Linking two modules of different target triples: /tmp/native13265186009735942822/cstubs.bc' is 'armv6-unknown-linux-gnueabihf' whereas 'out' is 'armv6kz-unknown-linux-gnueabihf'

w: Linking two modules of different target triples: /tmp/native627338979534854439/cstubs.bc' is 'armv6-unknown-linux-gnueabihf' whereas 'out' is 'armv6kz-unknown-linux-gnueabihf'

w: Linking two modules of different target triples: /tmp/native7458931769986923423/cstubs.bc' is 'armv6-unknown-linux-gnueabihf' whereas 'out' is 'armv6kz-unknown-linux-gnueabihf'
What do the warnings mean? It is important to note that the Linux ARM HFP 32 binary is created successfully. These warnings are confusing since the linuxArm32Hfp target is used, which is based on Linux ARMv7, not Linux ARMv6. The warnings above do not occur if Kotlin 1.5.20 is used instead of Kotlin 1.5.30. Looks like there is a major issue with linking for the linuxArm32Hfp target in Kotlin 1.5.30.
Here is a link to the project where the warnings occur: https://gitlab.com/gui-vista/samples/kpad
View count: 13