I used this command from tutorial “kotlinc-native...
# kotlin-native
g
I used this command from tutorial “kotlinc-native -target android_arm32 -output hello_android.cgi hello.kt -e sample.main” it gave me *.so file. But on Android I wasn’t able to run it from console. It said “Illegal instruction”. Unlike for mac it generated console executable successfully
o
Android
program
target produces native activity (https://developer.android.com/reference/android/app/NativeActivity), not console application.
g
is there a way to force kotlinc-native make elf executable, not NativeActivity?
I want to run executable from shell
d
A shell on android?
g
right
message has been deleted
d
Now that is very interesting.
g
well tbh I want to make cgi binary to be able to run over lighthttpd server on android using kotlin
but first I need that to make that executable
g
Does that mean that kotlin compiler won’t help? I assume I need to use gcc
d
It can, just pass the arguments through
-linkerOpts
.
You'll probably what to export a
main
with
@CName
.
Not sure if it'll work but it could. 🤷🏼
g
@Dominaezzz could you say what options should I specify for -linkerOpts?
my hello.kt is: “package sample fun hello(): String = “Hello, Kotlin/Native!” fun main() { println(hello()) }”
d
Hmm, maybe
-linkerOpts=-pie -Wl,-E
.
Nvm, this probably won't work.
g
😞
u
Is there an arm Linux Target? That could work for you
👍 1
d
There is one
linuxArm32Hfp
.
👍 1
u
After all, Android and especially the Shell is basically Linux. But it is not glibc so this could be a problem
g
On mac I don’t have linuxArm32 . Full list I have: macos_x64: (default) macbook, macos, imac ios_arm32: iphone32 ios_arm64: iphone, ipad, ios ios_x64: iphone_sim android_arm32: android_arm64: wasm32: zephyr_stm32f4_disco:
I will try to build linuxArm32 from Linux on virtualbox
but it’s not common scenario, so unlikely we will support it in the mainline compiler
g
@olonho will linuxArm32Hfp work fine on Android as console utility?
o
Unlikely, it’s glibc based and hard-fp, while Android is bionic-based and soft-fp
😞 1
g
@olonho so the single way to make console android app is to compile modified Kotlin Native sources?
o
yes, and note that technically there are no console Android apps, just it happens that Android has Linux kernel inside 😉. Also you could write universal wrapper loading native activity and use it to run K/N output, although I doubt it makes much sense.