Skip to content

Instantly share code, notes, and snippets.

@sonique6784
Created October 19, 2024 09:57
Show Gist options
  • Save sonique6784/ab3e4e58f09bf008ecb684dde3a5197a to your computer and use it in GitHub Desktop.
Save sonique6784/ab3e4e58f09bf008ecb684dde3a5197a to your computer and use it in GitHub Desktop.
Hello World Kotlin Native
# pre-requisite, install kotlinc-native
# $ brew install brew install --cask kotlin-native
kotlinc-native helloworld.kt
sleep 3
./program.kexe
sleep 3
dyld_info program.kexe
fun main() {
println("Hello World!");
}

When compiling with kotlinc-native compiler, the binary link with the system libraries such as libc++.

❯ ls -lh
total 1044
-rw-r--r--@ 1 sonique  staff    45B 19 Oct 20:43 helloworld.kt
-rwxr-xr-x@ 1 sonique  staff   1.0M 19 Oct 20:47 program.kexe
❯ dyld_info program.kexe
program.kexe [arm64]:
    -platform:
        platform     minOS      sdk
           macOS     11.0      14.0
    -segments:
        load-offset   segment section        sect-size  seg-size perm
        0x00000000    __TEXT                               368KB r.x
        0x00001DFC             __text           281300
        0x000468D0             __stubs            1872
        0x00047020             __stub_helper      1872
        0x00047770             __objc_methlist    2852
        0x00048294             __gcc_except_tab   6232
        0x00049AF0             __const           15568
        0x0004D7C0             __objc_methname    2070
        0x0004DFD6             __objc_classname    701
        0x0004E293             __objc_methtype     898
        0x0004E615             __cstring          2270
        0x0004EEF3             __oslogstring        25
        0x0004EF0C             __unwind_info     11864
        0x00051D68             __eh_frame        41616
        0x0005C000    __DATA_CONST                         112KB rw.
        0x0005C000             __got               128
        0x0005C080             __mod_init_func     272
        0x0005C190             __const          101152
        0x00074CB0             __cfstring          384
        0x00074E30             __objc_classlist    184
        0x00074EE8             __objc_nlclslist      8
        0x00074EF0             __objc_catlist       80
        0x00074F40             __objc_protolist     16
        0x00074F50             __objc_imageinfo      8
        0x00078000    __DATA                                32KB rw.
        0x00078000             __la_symbol_ptr    1232
        0x000784D0             __objc_const       4928
        0x00079810             __objc_selrefs      912
        0x00079BA0             __objc_protorefs      8
        0x00079BA8             __objc_classrefs    224
        0x00079C88             __objc_superrefs    168
        0x00079D30             __objc_ivar          88
        0x00079D88             __objc_data        1840
        0x0007A4C0             __data             3696
        0x0007B330             __thread_vars       192
        0x0007B3F0             __thread_bss         43
        0x0007B420             __bss              8352
    -dependents:
        attributes     load path
                       /usr/lib/libSystem.B.dylib
                       /usr/lib/libc++.1.dylib
                       /usr/lib/libobjc.A.dylib
                       /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
                       /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment