This is code for a video tutorial on how to make a native Windows library with Kotlin.
It's a modification of Kotlin/Native as a dynamic library – tutorial on the official Kotlin site.
There are two steps:
- build native library for Windows desktop
- use library in sample C program
> ./gradlew linkNative
BUILD SUCCESSFUL in 1s
4 actionable tasks: 1 executed, 3 up-to-date
Using Windows x64 Native Tools.
>lib /def:libnative.def /out:libnative.lib
Microsoft (R) Library Manager Version 14.29.30151.0
Copyright (C) Microsoft Corporation. All rights reserved.
LINK : warning LNK4068: /MACHINE not specified; defaulting to X64
Creating library libnative.lib and object libnative.exp
Using Windows x64 Native Tools.
>cl.exe main.c libnative.lib
Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30151 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
main.c
Microsoft (R) Incremental Linker Version 14.29.30151.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:main.exe
main.obj
libnative.lib
.\main.exe
in: Hello from Native!
out:That is 'Hello from Native!' from C
DemoClazz returned 42
custom greeting: Aloha, from Craig. This is inside a Kotlin class