Using C library functions in kotlin

时间:2017-12-18 08:08:46

标签: kotlin kotlin-native

I have been trying to follow this blog and I have run all the steps successfully but however when I run the last command

create table C as select A.code || '-' || B.year as status from A, B

I get errors which say sqrt,pow,fopen,fclose are all unresolved

konanc $COMPILER_ARGS -target macbook src/main/kotlin/logogen.kt -library build/c_interop/png -linkerOpts "-L/usr/local/lib -lpng" -o build/bin/logogen

This is what is in my png.def file

error: unresolved reference: sqrt

Imported it in my logogen.kt file as

headers = /usr/local/include/png.h stdio.h stdlib.h string.h math.h

Thank you!

2 个答案:

答案 0 :(得分:1)

<{1}}文件中的

compilerOpts = -lm可以解决问题。

答案 1 :(得分:0)

你在用$COMPILER_ARGS代替什么?大概你传递了那些定义那些C引用的C库,以及程序所需的C库。例如,对于sqrt undefined reference you would add '-lm'。对于编译器告诉您缺少的任何其他内容也是如此。