why kotin multiplatform project can generate dll f...
# multiplatform
p
why kotin multiplatform project can generate dll file,but in windows c# project cannot be imported? Can someone help me,thanks a lot in build.gradle config like this : mingwX64(“native”)*{* binaries*{* sharedLib { baseName = “libnative” } } }
👀 2
🫡 1
😄 1
e
Hey off the bat I will say my knowledge on this is limited but I wanted to throw out the fact that the DLL internal format may be different. Have you tried this with a C++ or C application , prefereably also using mingw?
c
Do you want to call C# DLL from a Kotlin project? Have you developed any C++ program that calls a C# dll? You may have used C++/CLI or C++/CX (not a plain C++), because you should embed .NET runtime (or Mono) to your C++ project to call a C# dll. As in C++, you should also embed .NET or Mono in your Kotlin application.
If you want to interop C# and Kotlin, calling Kotlin from C# would be much easier.
1
If you want to call Kotlin from C#, the following code should work:
Copy code
[DllImport("libnative.dll")]
static extern IntPtr /* or a pointer to a struct */ libnative_symbols();
@Bernat I've just seen the message, sorry for the late reply. I've also just found that Kotlin does not generate indexers for arrays. How about defining a helper function like this?
Copy code
fun arrayGet(array: Array<Any>, idx: Int) = array[idx]
fun arraySet(array: Array<Any>, idx: Int, value: Any) {
    array[idx] = value
}