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
Enahor Tapmas
02/18/2024, 7:08 AM
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
Chanjung Kim
02/20/2024, 10:43 AM
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.
Chanjung Kim
02/20/2024, 10:44 AM
If you want to interop C# and Kotlin, calling Kotlin from C# would be much easier.
✅ 1
Chanjung Kim
02/20/2024, 10:48 AM
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();
Chanjung Kim
02/06/2025, 3:37 AM
@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
}