Questions tagged [cinterop]

29 questions
3
votes
0 answers

How to use cinterop in Kotlin Multiplatform Mobile projects

I want to integrate C code into a Kotlin Multiplatform Mobile project using the cinterop tool. I already spent some time on the documentation on Kotlin Multiplatform and Kotlin/Native but I can't seem to get it working. Here is my…
2
votes
0 answers

Kotlin/Native How to include C-interop headers in the artifact?

I've added the headers like so in the build.gradle.kts file: linuxX64 { val main by compilations.getting main.cinterops.create("x11") { defFile("src/linuxX64Main/cinterop/x11.def") compilerOpts.add("-I" +…
Animesh Sahu
  • 7,445
  • 2
  • 21
  • 49
2
votes
1 answer

Can I safely use a string_view if I need to eventually need to get a char pointer?

I'm working on some C++ code that also eventually needs to call OS-level C code, for example scandir. I'd like to use C++ for most of the codebase, which (to me) means that I'm mostly working with std::string instead of char pointers. I have a…
Michael Stum
  • 177,530
  • 117
  • 400
  • 535
2
votes
1 answer

Where to find (install) Kotlin cinterop tool on Mac

I would like to try to build Kotlin/Native project with dependencies on some library. As documentation explains, I need to create def file (which I was already created) and run cinterop tool. However, I wasn't able to find this tool on my Mac and…
Andrey
  • 2,659
  • 4
  • 29
  • 54
1
vote
0 answers

In Kotlin Multiplatform, using gradle.kts, how do I determine the compilers used for targets like linuxX64, mingwX64, and mac/ios?

I need to know what compilers are being used so I can compile my C++ code with them. I tried using the standard host compilers (for when the target == my host) and it did not work due to undefined standard library symbols. I was able to find the…
AndrewStone
  • 517
  • 4
  • 14
1
vote
1 answer

Access tuple (defined by libc) using an index

I understand that Swift tuples cannot be indexed at runtime. However, I'm working with the POSIX terminal interface (defined by , which is part of libc). In the C code, we are able to modify the state of the terminal by doing stuff like…
CYPS84
  • 13
  • 4
1
vote
1 answer

How to send a `vararg variadicArguments: kotlin.Any?` to a GObject native call with Kotlin Native?

I'm working on a GIR generator to create Kotlin Native bindings for GTK and other GObject based libraries. I reached a stage where I can almost compile the bindings for GLib but I'm stuck with the handling of varargs. For example…
1
vote
1 answer

How can I build a libcurl Kotlin Native application on Windows?

I'm relatively new to Kotlin Native, and to learn more about it, I am studying these two tutorials, one from the official JetBrains documentation and the other from the jonnyzzz blog, both focused on creating an application using C Interop and…
Alopex
  • 131
  • 1
  • 1
  • 8
1
vote
2 answers

Kotlin/Native : How to import entire GTK4 Libs and headers to Kotlin Native C Interop?

I am learning C Interop with Kotlin Native. I successfully imported my sample C program using .Def file and executed the code in kotlin So, I am thinking about import GTK4 libs, which is in C, to Kotlin/Native project and try a GTK app there But…
RagAnt
  • 1,064
  • 2
  • 17
  • 35
1
vote
2 answers

Does the documentation or language definition for R remark on the intended usage of R's integers?

A common comment that I see made about R's integer type is that it's only really intended for communication with C code. Do any statement like this appear in any official part of R's documentation? I often catch myself making vectors like…
J. Mini
  • 1,868
  • 1
  • 9
  • 38
1
vote
0 answers

Kotlin's cinterop .def wont work with relative paths

I have a static library that needs to link to other static libraries. When I attempt to run ./gradlew common:cinteropSomeLibIos : I always get IllegalStateException: Could not find 'libabseil.a' binary in neither of [external/lib] my def…
Maurycy
  • 3,911
  • 8
  • 36
  • 44
1
vote
0 answers

How can I write bindings for the given C structure using dart ffi?

I was trying to write dart ffi bindings for the following C structure but I'm getting errors of all sorts. Can somebody help me with this? typedef struct { enum CXCursorKind kind; int xdata; const void *data[3]; } CXCursor; Also for the…
bitbeast18
  • 41
  • 1
  • 4
1
vote
2 answers

Kotlin/native cinterop build problem with gradle

I'm experimenting with Kotlin native and iOS. I tried to use the example at raywenderlich as a starting point. This example is a bit old , so I have updated the code to fit the Kotlin multiplatform 1.3.61. I'm using AppCode to build the code. I'm…
Trond Tunheim
  • 115
  • 10
1
vote
1 answer

Kotlin Native: C objects ownership and lifespan

I've been trying to wrap CPointer types of native objects with the idea that the object controls the lifespan of the underlying native object. In C++ terms, I would do something like: class T { private: U other; }; Or even: class T { public: …
Sigma Octantis
  • 903
  • 1
  • 8
  • 25
0
votes
0 answers

Including Objective-C library in kotlin mutliplatform project

I'm trying to include an objective-c library into a Kotlin multiplatform project. If I do it with this hierarchy structure, like it is described in the docs it works: Objective-C library -> main Kotlin multiplatform module (called "shared") -> iOS…
Balazs
  • 35
  • 4
1
2