June 25, 2023

native Kotlin on Fedora

I am running Fedora 38 on the usual x86_64 desktop.

At this time 1.8.22 is the latest release and 1.9 is in the works. The 1.8.22 file is 3 weeks old. I download:
kotlin-native-linux-x86_64-1.8.22.tar.gz
This is a 192M file.
cd /u1
tar xvf kotlin-native-linux-x86_64-1.8.22.tar.gz
rm kotlin-native-linux-x86_64-1.8.22.tar.gz
ln -s kotlin-native-linux-x86_64-1.8.22 kotlin
cd kotlin/bin
ln -s ln -s kotlinc-native kotlinc
This puts it into a directory /u1/kotlin-native-linux-x86_64-1.8.22 They suggest putting /u1/kotlin-native-linux-x86_64-1.8.22/bin on your path. With the link I created, I can put /u1/kotlin/bin on my path. I do that by editing .bashrc and adding this line:
export PATH=/u1/kotlin/bin:$PATH
Now I try compiling a trivial "hello.kt"
kotlinc hello.kt
This downloads a bunch of dependencies into /home/tom/.konan the first time. Then it produces "program.kexe" which I can run via:
[tom@trona tom]$ ./program.kexe
Hello, World!
Note that this is not producing Java .jar files or .class files. It seems to be producing native code, bypassing dependency issues on the JRE. Not what I expected, but very likely a lot better.

For help:

kotlinc -help

Note that typing "kotlinc hello.kt -o hello" yields "hello.kexe".


Have any comments? Questions? Drop me a line!

Adventures in Computing / [email protected]