Questions tagged [ffi]

A foreign function interface (FFI) is a mechanism for one language to interact with software written in another language.

1778 questions
0
votes
1 answer

Dart FFI type mappings

I'm making a Dart library that uses FFI to interact with Rust code and I have some questions. I couldn't find any official information about native interop behavior and I've been steering only by other examples and Dart SDK code. For instance, Dart…
pak3nuh
  • 11
  • 4
0
votes
0 answers

Is it possible to write into a Rust data pointer handed over from an external function call while accessing the data pointer from outside?

Let's assume we have a software module with a data structure in Rust, which can do a specific computation taking a list of numbers as input. We would like to access this module from outside, e.g. C++. As the computation is processed number-by-number…
Nevsden
  • 99
  • 6
0
votes
1 answer

PHP FFI possible on ARMv8?

I can load my library through the FFI on x86_64 but not on AArch64. FFI::cdef( /* ... */, $root . './build/libuplink.so' ); PHP Fatal error: Uncaught FFI\Exception: Failed loading '/home/linaro/uplink-php/build/libuplink.so' in…
Erik van Velzen
  • 6,211
  • 3
  • 23
  • 23
0
votes
1 answer

How do I pass a non-mutable reference from Rust to a C-API that doesn't use const (even though it should)?

I have a wrapper around a C-API: #[repr(transparent)] pub struct Request(http_request_t); This wrapper provides several methods for interacting with the request: impl Request { pub fn bytes_received(&self) -> usize { unsafe { …
dcoles
  • 3,785
  • 2
  • 28
  • 26
0
votes
0 answers

Golang calling Windows DLL function with more than 18 arguments

I have an external 64 bit .DLL and I have to pass 22 arguments to one of the functions. Go (go1.16.4 windows/amd64) allows up to 18 arguments. Is there any workaround? Thanks
xc218m
  • 69
  • 6
0
votes
0 answers

How to import jars by JNI-rs

I'm trying to use some dependencies in JNI-rs. The following is the class which I need to use: org.quartz public class JobDataMap extends org.quartz.utils.StringKeyDirtyFlagMap implements java.io.Serializable Maven:…
slhmy
  • 11
  • 4
0
votes
1 answer

How use UEFI locate_protocol in a rust project with r_efi crate

In a cross-compiled educative project with rust and the crate r_efi and without the rust standard library, I wanna make a small program to UEFI systems. For the moment, the goal is to be able to use the graphical output protocol. Through the use of…
ExecAssa
  • 177
  • 11
0
votes
0 answers

How to read a returned Rust dll pointer from Python

I want to return a f64 vector from Rust to Python and I'm not sure how to dereference the returned pointer in Python side. lib.rs use libc::c_double; #[no_mangle] pub extern "C" fn give_me_array() -> *const Vec { let array_to_pass =…
mbfernan
  • 13
  • 5
0
votes
1 answer

Access elements of a static fixed size array from a DLL in another DLL in Rust

I'm compiling some information of an object into an .so, like: #[no_mangle] pub static a: [f32; 10] = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]; (simplified of course) I need to have access to its values from another .so and thinking on…
mbfernan
  • 13
  • 5
0
votes
1 answer

How can I link user32.lib for an i686 application (Windows)

I'm attempting to target i686-pc-windows-msvc, but this code extern "C" { pub fn GetDC(hdc: *const c_void) -> *const c_void; } fails to compile with "C:\\Program Files (x86)\\Microsoft Visual…
0
votes
1 answer

Flutter Desktop C++ embed

I wanted to know if Flutter supports C/C++ embed via ffi for Desktop applications? I know you can do it for iOS and…
0
votes
1 answer

Ruby Fiddle - Cannot find function in WIndows MSYS2

I am trying to use Ruby Fiddle to access a C function I have developed. The C code is: #include #include #include double *linalg_positive_matrix(double *mat_a, int rows_a, int cols_a); int main(void) { } double…
Rojj
  • 1,170
  • 1
  • 12
  • 32
0
votes
1 answer

Create struct in C/Rust code for Node-FFI

I am trying to return a struct from a Rust function to Node.js, the struct is nested, and contains an array so it is sufficiently complicated that I want to do the allocation in Rust and have Node.JS receive a complete object, here's the Rust code…
Lee Hambley
  • 6,270
  • 5
  • 49
  • 81
0
votes
1 answer

Rust FFI: function with multiple string pointers; first parameter has aggregated value from subsequent string pointers

Below, I have simple function with two string pointers parameters. First parameter is expression (i.e. value = "foo") and second parameter is json (i.e. value = {"foo":{"bar":{"baz":true}}}). When I execute the test I get the…
TiKi
  • 15
  • 3
0
votes
1 answer

How to call the function glMultiDrawElements :: GLenum -> GHC.Ptr.Ptr GLsizei -> GLenum -> GHC.Ptr.Ptr (GHC.Ptr.Ptr a) -> GLsizei -> IO ()

The ffunction glMultiDrawElements requires a pointer to a pointer as one of its arguments. How might one obtain a Ptr(Ptr a) from a StorableArray Int a ?
Eric
  • 51
  • 2
1 2 3
99
100