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
  • a

    Andy Victors

    05/23/2019, 12:30 PM
    Hello all, I've read all on KN concurrency but still cannot figure out how to model this: • There is an
    DataFetcher
    and `DataStorage`classes, for getting data from remote to storing it, well, into the storage object • The list of
    DataFetchers
    is global, but mutable using `frozenCopyOnWriteList<>`from
    Stately
    lib => therefore all Fetchers are frozen • To tell a Fetcher which storage he needs to store the date into, I pass the Storage object in constructor. • PROBLEM: since Storage is then in the same object graph as the Fetcher, Storage becomes frozen. But it's counter-goal for a storage object. There should be a pattern for that, isn't it?
    k
    • 2
    • 17
  • r

    ribesg

    05/23/2019, 12:43 PM
    I need to pass a
    kotlinx.cinterop.CPointer<kotlinx.cinterop.ObjCObjectVar<platform.Foundation.NSError?>>?
    to an ObjC function, is it how you do it?
    var error: NSError? = null
        val errorPtr = ObjCObjectVar<NSError?>(error.objcPtr()).ptr
    👍 1
    k
    s
    • 3
    • 7
  • i

    Ivan

    05/23/2019, 4:24 PM
    Hi guys, have a question here. I have few kn modules 1. knmoduleOne 2. knModuleTwo 3. knMain and main have first two as libs inside like this sourceSets { commonMain { dependencies { api project(":knmoduleOne") api project(":knModuleTwo") }}} when Im building it into ios lib, the classes from modules 1 and 2 have prefix in their names like KNMODULEONESomeClassName. Its kinda triggering, how to avoid that? just rename module during build or there is another way?
    t
    y
    • 3
    • 4
  • b

    basher

    05/23/2019, 4:32 PM
    When you call
    allocArray
    , does it zero your memory, or do you have to use
    memset
    ?
    d
    • 2
    • 8
  • n

    napperley

    05/24/2019, 6:13 AM
    What is required to get code completion to work in IntelliJ for a C library?
    g
    m
    • 3
    • 35
  • p

    Paul Idstein

    05/24/2019, 6:28 AM
    I see the following error, when using on iOS simd_float4x4 references: type CValue<simd_float4x4> of return value is not supported here: not a structure or too complex. Any idea how to use accelerate types? Also simd_float2 or simd_float3 are not visible at all. Should map to a float*
    o
    • 2
    • 2
  • t

    Tukor Ferenc

    05/24/2019, 12:48 PM
    Hi, I have a question about memory management In the source of the Kotlin Runtime, inside Memory.cpp (https://github.com/JetBrains/kotlin-native/blob/20d3e12e7cdc60af02d7e7c4620f4b577b1141c8/runtime/src/main/cpp/Memory.cpp) I found this:
    // If garbage collection algorithm for cyclic garbage to be used.
    // We are using the Bacon's algorithm for GC, see
    // <http://researcher.watson.ibm.com/researcher/files/us-bacon/Bacon03Pure.pdf>.
    #define USE_GC 1
    Does this define control all GC behaviour? If I set it to zero have I achieved manual memory management in all cases? Is there an easy to control option for this in any IDE that supports Kotlin or do I have to build my own runtime with the option set the way I want and then manually bind that runtime to my project?
    n
    • 2
    • 3
  • d

    Dominaezzz

    05/25/2019, 3:39 PM
    How likely is debugging in IntelliJ Ultimate? Are there any soon-ish plans for this?
    b
    k
    o
    • 4
    • 3
  • n

    napperley

    05/26/2019, 1:12 AM
    Spotted some mistakes in the 2nd code sample inside the Kotlin/Native as a Dynamic Library ( https://kotlinlang.org/docs/tutorials/native/dynamic-libraries.html ) article. The Linux version uses macosX64 as the target, and the MacOS version uses linuxX64 as the target. The targets should be reversed.
    😮ctocat: 1
    j
    • 2
    • 1
  • n

    napperley

    05/26/2019, 4:00 AM
    Does the Kotlin Native version of the Kotlin Standard lib have functionality to intercept process interrupts/signals (eg when a user presses Ctrl+C)? Want to intercept a keyboard interrupt event, and cleanup resources before exiting the program.
    o
    • 2
    • 1
  • r

    Rohan Maity

    05/26/2019, 10:19 AM
    is there a way to run generated kexe file from IntelliJ Idea?
    fun main() {
        val numbers = readLine()?.split(',')?.map {
            it.toInt()
        }
        println(numbers?.sum()?:"No Numbers")
    }
    I have written this code that takes input. When I run from terminal
    ./file.kexe
    it works fine. But I want to create run configuration for running generated kexe file
    which would take input also
    like it does with
    ./file.kexe
    a
    g
    i
    • 4
    • 6
  • m

    Marc Knaup

    05/26/2019, 10:45 AM
    I'm trying to run tests on the iOS simulator. iOS test code is common test code only. It crashes in
    Memory.cpp
    and I have no hint what is causing this 😕 Does anybody have an idea?
    Found the cause. See comments. Sources: https://github.com/fluidsonic/fluid-time/tree/native-testing Output:
    $ xcrun simctl spawn "iPhone 8" "/Users/marc/Documents/fluid-time/build/bin/iosX64/testDebugExecutable/test.kexe"
    /Users/teamcity/buildAgent/work/4d622a065c544371/runtime/src/main/cpp/Memory.cpp:1216: runtime assert: memory state must be clear
    Child process terminated with signal 6: Abort trap
    j
    • 2
    • 3
  • r

    Rohan Maity

    05/26/2019, 2:10 PM
    While I was doing
    cinterop
    for
    stack
    header file in c++. I encountered
    Exception in thread "main" java.lang.Error: /usr/include/c++/7/bits/functexcept.h:42:1: error: unknown type name 'namespace'.
    Is kotlin/native unable to determine
    namespace
    ?
    o
    m
    • 3
    • 15
  • k

    kpgalligan

    05/26/2019, 3:51 PM
    See ‘producer’ section here: https://medium.com/@kpgalligan/kotlin-native-stranger-threads-ep-1-1ccccdfe0c99
    m
    • 2
    • 5
  • m

    Marc Knaup

    05/26/2019, 5:05 PM
    What's the easiest way to debug the native compiler (in a multiplatform project)?
    k
    • 2
    • 9
  • m

    mansonheart

    05/26/2019, 7:17 PM
    @kpgalligan Sorry for strange question about test 🙂 I undestand your example about the User factory. But I 'm not finding usecase for detach object feature and can't undestand this feature fully. My naive thoughts is below in code 🙂. I had provided some comments about that. Looks like I need to write some production code to see concurrent patterns in Kotlin.
    -.kt
    a
    k
    • 3
    • 4
  • j

    jeremy

    05/26/2019, 11:45 PM
    How to unit test exceptions in KN? @Test(expected = Exception::class) results in error Cannot find a parameter with this name: expected
    d
    a
    • 3
    • 4
  • t

    Timothy Wong

    05/27/2019, 7:40 AM
    Good day all, I was wondering if someone can link me some resources with using dynamic libraries with Kotlin Native -- Looking online gives me a surplus of articles of making an executable a dynamic library, and I am not the most familiar with the Kotlin Native ecosystem at the mment Edit: I looked through the available sample code at https://github.com/JetBrains/kotlin-native/blob/master/samples/curl/build.gradle, and I'll see how much success I have 🙂
    d
    • 2
    • 4
  • j

    jeremy

    05/27/2019, 4:00 PM
    Are any additional dependencies required to use Worker class outside of stdlib?
    d
    k
    +3
    • 6
    • 51
  • m

    McEna

    05/28/2019, 3:42 AM
    Hey folks, is it possible to use OpenJDK for kotlin-native, or is Oracle's JDK still required?
    n
    a
    • 3
    • 3
  • t

    Tukor Ferenc

    05/28/2019, 12:17 PM
    hi is it possible to turn off all automated memory management for Kotlin/Native? if yes, how? is there a convenient way to do it?
    o
    j
    s
    • 4
    • 5
  • k

    Ken Gilmer

    05/28/2019, 4:41 PM
    hello 🙂 . I wish to package a kotlin native program as a Debian source package. From my searches it doesn't appear that kotlin-native is a supported toolchain by Debian. Is this simply something that needs to be contributed by someone or is there more to the story?
    o
    • 2
    • 4
  • m

    McEna

    05/28/2019, 7:23 PM
    Hello to everyone. I have a tricky question. I have a multiplatform library project and I intend to consume it in non-kotlin projects (IE: regular java, macOs, javascript). How do I publish the artifacts outside of Maven? I know I can just open the jar files and get the binaries, but I want to see if there's a more structured solution, like publishing the javascript module to npm, or in a ready to be deployed to npm format, for example.
    k
    d
    • 3
    • 9
  • m

    Marc Knaup

    05/28/2019, 8:52 PM
    How is an
    inline class
    represented in ObjC when it's boxed to
    Any
    ?
    let value: Any = someMap[…]
    print(type(of: value)) // kobjcc3
    print(value) // UiColor(argb=-570425344) - a wrapped Int (i.e. Int32 in ObjC)
    as! Int32
    doesn't work
    as! KotlinInt
    doesn't work
    as! NSNumber
    doesn' work In all non-generic contexts the value is represented as
    Int32
    . I also can't cast it to a protocol in case it implements an interface 😕
    • 1
    • 1
  • t

    Timothy Wong

    05/29/2019, 5:53 AM
    Hi all, can someone point me in the right direction for compiling for Raspberry Pi from other Linux Distributions? Thank you. Edit: I am hoping to do it via the gradle multiplatform kotlin native build architecture
    g
    • 2
    • 8
  • t

    Timothy Wong

    05/29/2019, 6:52 AM
    I am using the echoserver raspberry pi example for reference, and grade is living me an error that 'MPPTools' doesnt exist
    o
    • 2
    • 2
  • v

    victor herasme perez

    05/29/2019, 10:15 AM
    Hello. I have recently bought a book on NDK and I found that most of it teaches you to use JNI with your Java/ Kotlin code. I wonder if a better approach would be to use Kotlin native
    g
    n
    • 3
    • 21
  • t

    Timothy Wong

    05/29/2019, 11:23 AM
    Hi all once more, my apologies for the abudance of questions, I am quite new to this technology, and as a project I am hoping to port a few simple things I made in C into Kotlin/Native. The biggest problem is that it is not easy to compile Kotlin Native on a raspberry pi, it took me a really long time to compile a simple hello world application! I do though, want to access the WiringPi library, which allows you to work with the GPIO pins on raspberry pi's. The library is already installed on Raspberry Pi's, and unfortunately the creator does not distribute static files, and only the .so files which can be only installed on a raspberry pi, from what i've been able to research. My question is, if I want to use the library's functionality within a Kotlin Native project, I know that I would have to use it as a dynamic library, but how would I go about linking it to my project? Would that be possible, or would I have to stick to waiting for a long time while it compiles on the raspberry pi. I also thought of the idea of copying the .so files from the raspberry pi into my workspace on my mac computer, and linking it through that way. I'm not sure whether this would work or not, and I would like to know what is the best course of action I should take, or just stick to C and not attempt this
    k
    n
    • 3
    • 10
  • t

    tylerwilson

    05/29/2019, 2:07 PM
    I need a smidge of help. I am porting some ObjC code to Kotlin Native. It is just a few lines that call into CoreCrypto. Fortunately, I see everything wrapped already, which is great. The original code is like so:
    CCHmacContext context;
    CCHmacInit(&context, algorithm, keyCString, strlen(keyCString));
    I am unclear on how to create the context and pass in the Kotlin version. The first context param is declared as CValuesRef<CCHmacContext>? So how do I construct this CValuesRef type? Thank you. Any similar code would be cool too.
    s
    • 2
    • 1
  • c

    caffeine

    05/29/2019, 3:23 PM
    Hello. I have gradle multimodule project. I have the project
    :ssl
    , and he needs
    -lssl
    for linking. This project builds normally with linkOpts
    -lssl
    Also, I have
    :httpServer
    project. Then I add
    :ssl
    as a dependency to
    :httpServer
    and after I try to build it. On linking I catching errors they say that argument
    -lssl
    is not added tp linkOpts. What I must do to fix this error. For example, I can add
    -lssl
    to
    :httpServer
    but I don't want to do this, because I already added this arg to
    :ssl
    . I don't want to add
    -lssl
    to each project who using
    :ssl
    and
    :httpServer
    d
    • 2
    • 10
Powered by Linen
Title
c

caffeine

05/29/2019, 3:23 PM
Hello. I have gradle multimodule project. I have the project
:ssl
, and he needs
-lssl
for linking. This project builds normally with linkOpts
-lssl
Also, I have
:httpServer
project. Then I add
:ssl
as a dependency to
:httpServer
and after I try to build it. On linking I catching errors they say that argument
-lssl
is not added tp linkOpts. What I must do to fix this error. For example, I can add
-lssl
to
:httpServer
but I don't want to do this, because I already added this arg to
:ssl
. I don't want to add
-lssl
to each project who using
:ssl
and
:httpServer
d

Dominaezzz

05/29/2019, 3:53 PM
Did you add that in the def file or via gradle?
You'll have to do it via the def file if you want your dependencies to not have to add it.
c

caffeine

05/29/2019, 6:39 PM
I added -lssl into gradle. Now I try to move this to def file and build my
:httpServer
. As result
httpServer
can't find
*.a
files because this
*.a
not a part of embedded mingw. When I build
:ssl
I added custom path to
*.a
files
d

Dominaezzz

05/29/2019, 6:40 PM
Did you add the custom path via gradle? Or the def file.
You could always just bundle the
*.a
files and forget about linking altogether.
c

caffeine

05/29/2019, 6:41 PM
This custom path in project directory. I can't define relative path in def file.
You could always just bundle the
*.a
files and forget about linking altogether.
how?
d

Dominaezzz

05/29/2019, 6:42 PM
https://github.com/JetBrains/kotlin-native/blob/master/INTEROP.md#including-static-library-in-your-klib
Although you'll have the same relative path issue.
You can specify a path relative to your project directory. That's what the def file uses by default (....ish).
View count: 7