Does the Konan Gradle plugin have a way to setup e...
# kotlin-native
n
Does the Konan Gradle plugin have a way to setup environment variables? Trying to run the weather program (was successfully compiled and linked) through Gradle, but an error appears:
Copy code
> Task :runWeather FAILED
/home/napperley/repos/openfaas-weather-sample/build/konan/bin/linux_x64/weather.kexe: error while loading shared libraries: libcjson.so.1: cannot open shared object file: No such file or directory
g
The same as with Gradle Groovy You can use environment variables
for run task would be probably better to modify run task itself and pass variables there
n
Tried that via
Copy code
tasks.withType<JavaExec>{ doFirst { //... } }
but it didn't have any effect. 🙁
g
Do you want use libcjson as shared library? Maybe easier just to use it as static library? especially for your case
👍 1
I don’t think that konan
run
task is inherited from JavaExec
but probably can do that directly to gradle, something like: MY_ENV_VAR=something ./gradlew run
n
Probably should also look into using libcurl as a static library too, unless Kotlin Native has a way of statically linking a KLib into a Kotlin Native program (binary).
Had a look at what libcurl needs for static linking by running the following:
Copy code
curl-config --static-libs
/usr/lib/x86_64-linux-gnu/libcurl.a -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed -lidn -lrtmp -lssl -lcrypto -lssl -lcrypto -Wl,-Bsymbolic-functions -Wl,-z,relro -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -llber -llber -lldap -lz
Tried appending everything after "libcurl.a" to compilerOpts.linux in the definition file, however it doesn't work with libcurl. Tons of "undefined reference" errors are appearing ☹️.