hhstore / blog

My Tech Blog: about Mojo / Rust / Golang / Python / Kotlin / Flutter / VueJS / Blockchain etc.
https://github.com/hhstore/blog/issues
276 stars 22 forks source link

Rust: FFI(Foreign function interface) #355

Open hhstore opened 2 years ago

hhstore commented 2 years ago

related:

hhstore commented 2 years ago

Rust + FFI 绑定 core lib 给其他语言调用:

Rust + FFI 方案:

搜索包:

1. 💎💎💎 主调方(as Caller): Rust call C/C++

tools:

示例参考项目:

👿👿👿👿 Mac M1 兼容性问题:

教程:

2. 💎💎💎 被调方(as Callee): C/C++ call Rust

tools:

教程:

3. 💎💎💎 双向桥: rust vs c++

4. 其他:

hhstore commented 2 years ago

Rust + FFI + Flutter:

with Flutter:

Rust + FFI + Flutter 典型案例:

一个漫画阅读器:

hhstore commented 2 years ago

Rust + FFI + Java(JNI):

hhstore commented 2 years ago

Rust FFI (被调方):

工具链: cbindgen

参考:


# 安装: 
cargo install --force cbindgen

# 生成: 
cbindgen --config cbindgen.toml --crate my_rust_library --output my_header.h
hhstore commented 2 years ago

Rust + FFI + Mac M1 问题: