Hi, I have used cinterop for android in kotlin nat...
# kotlin-native
m
Hi, I have used cinterop for android in kotlin native successfully in the past but when now I try the same thing for windows, Kotlin native is not able to build it. I keep getting e: C:\Users\t-mapodd\.konan\dependencies\msys2-mingw-w64-x86_64-clang-llvm-lld-compiler_rt-8.0.1/bin/clang++ invocation reported errors I thought, that function definitions are not important in compile time and hence just with the header file it would build similar to what I did for android but it's not able to build without function definition it seems. Has anyone worked with cinterop in mingw(windows target) in kotlin native?
a
Hello, @Mananpoddarm! Are you talking about trying to interop on a different platform, using the same headers as input, but with no underlying library?
m
yes. I will provide the underlying library in runtime on the different platform itself. It worked for android but somehow, it's trying to find the function definitions while building only for windows
a
Building executable includes linking stage, so I’m not sure how it should work. Why don’t you provide definitions for the compile-time? Also, IIRC you can use the cinterop tool without function definitions, but it will only make IDE highlighting available (because bindings are being generated based on declarations). On build, this construction will fail - as the linker won’t be able to link functions declared in the header.
m
I am not able to provide paths to tensorflow.dll to resolve this issue using compilerOpts or linkerOpts. Also, I don't even want to build executables. I just want to build the library(.dll) That's why I am not sure on why it is even trying to link.
a
Consider looking through this sample, it’s
includeDirs
and
linkerOpts
should work fine for you, excepting you has to set the latter in the sharedLib{…} block instead of the executable{…} one.
m
Thanks @Artyom Degtyarev [JB] It built successfully.
I just had to use linkerOpts the way given in the repo you mentioned. Thanks:)
🎉 1