I'm trying to use the cinterop tool and it keeps s...
# kotlin-native
a
I'm trying to use the cinterop tool and it keeps saying that it can't find the headers I put in my .def file. The docs say they should be relative to the def file but no matter how I put the path to my headers, it still says that it can't find my headers. Am I supposed to put compiler/linker options? I don't see other examples doing so. The tool doesn't give much information about why it can't find the headers, just says it can't find them. My def file is just a single line of
headers = include/hidapi.h
.
It should be noted that I'm running on windows and the docs have the examples running on linux so I'm not quite sure how to translate the paths from linux to windows. I know how the paths work just not sure how the arguments for compiler/linker options are supposed to be done on windows
Copy code
C:\Users\Alex\Desktop\hidstuff>cinterop -def libs/hidapi/hidapi.def -o out/cinterop/hidapi
Exception in thread "main" java.lang.Error: C:\Users\Alex\AppData\Local\Temp\tmp5060895529418316192.c:1:10: fatal error: '/include/hidapi.h' file not found
        at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:145)
        at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.indexDeclarations(Indexer.kt:932)
        at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.buildNativeIndexImpl(Indexer.kt:922)
        at org.jetbrains.kotlin.native.interop.indexer.NativeIndexKt.buildNativeIndex(NativeIndex.kt:56)
        at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:245)
        at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:36)
        at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:88)
        at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:18)
This is the error given to me btw
The header is located in C:\Users\Alex\Desktop\hidstuff\libs\hidapi\include\ and the def is in C:\Users\Alex\Desktop\hidstuff\libs\hidapi\ so my def should be pointing to the header with
include/hidapi.h
right?
Found a github issue that said to run with -compilerOpts -I and I got a KotlinNullPointerException
I got it nevermind
k
What was it? The suspence!
d
In your build.gradle, add a
includeDirs("includePath/include")
Then in your file-
headerFilters=hidapi.h
a
I'm not using gradle
The problem had to do with relative paths.
I don't remember exactly cause I'm now dealing with a linking problem. Kotlin Native recognizes the klib I generated but when I try invoking a function in that klib, it says "undefined reference to `..`". When I call the function without param arguments (since it takes arguments) then I get errors saying "no value passed for parameter '..'"
Now I'm just confused. I'm thinking that the function I'm trying to call isn't actually being linked to the c lib that I'm trying to link so it has no idea what my function is pointing to
But I have no other errors or details. I wish I did
s
Have you tried adding linker options to
.def
or passing them when compiling the program?
a
Yes I have
I'm actually starting to think that it's a problem with the dll that I got from a different project. I don't know how the dll was created so I'm gonna create the dll myself