https://kotlinlang.org logo
Title
k

kitto

02/02/2023, 5:41 PM
Hello, I'm trying to use '*cinterop*' tool (from this tutorial: https://kotlinlang.org/docs/native-c-interop.html#simple-example) to see how static C bindings would look like. I made a single C function, and def file and I call from within cinterop folder:
[ridicolous relative path].konan/kotlin-native-prebuilt-macos-aarch64-1.7.20/bin/cinterop -def App.def
and I get:
Exception in thread "main" java.lang.Error: /var/folders/80/ncv5m6mj2yq0zg6nnn0cl46c0000gn/T/8421264523268807030.c:1:10: fatal error: 'App.h' file not found
I called it from the folder where 'App.h' is located, and I have no idea about this path in error message. Does cinterop supposed to work on macOS right now? How can I make my chances of success better :x
a

Adam S

02/02/2023, 7:21 PM
cinterop works on macOS for sure! So something else must be wrong You need to tell cinterop where to look for
App.h
with a linkerOpt that starts with
-L
linkerOpts = -L/relative/path/to/dir-that-contains-headers/
What’s the content of
App.def
? Also, how did you install Kotlin Native? If you use Homebrew then you can just call
cinterop
without the ridiculous relative path
k

kitto

02/02/2023, 8:05 PM
oh, I've seen that's "android studio and kotlin MP plugin" is best way to go, so it comes from plugin files I belive. I didn't try to use homebrew to get an instance of cinterop
I left the office right now, but App.def just had header to App.h which is a single test function
@Adam S Sorry to go back to this subject, but what version of java for mac should I use with
cinterop
from homebrew
a

Adam S

02/06/2023, 5:34 PM
no problem! I have Java 11, but I think any above 8 and below 17 should work