go-cshared-examples icon indicating copy to clipboard operation
go-cshared-examples copied to clipboard

Rust example

Open 0xjjoyy opened this issue 4 years ago • 2 comments

Hi,

It would be helpful if there was a Rust example.

I tried though wasn't able to get the linking flags to compile.

Cargo.toml

[package]
name = "client_rust"
version = "0.1.0"
authors = ["example"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
libc = "0.2"

src/main.rs

use libc::c_long;


#[link(name = "awesome", kind="dylib")]
extern {
    fn Add(num1: c_long, num2: c_long) -> ();
}

fn main() {
    unsafe { Add(5,5); }
    println!("Ran the unsafe code.");
}

0xjjoyy avatar Jun 06 '20 16:06 0xjjoyy

Examples https://github.com/0xjjoyy/go-cshared-examples

0xjjoyy avatar Jun 08 '20 03:06 0xjjoyy

Hi can you send over a PR for this ?

vladimirvivien avatar Jul 15 '20 21:07 vladimirvivien