Skip to content

Instantly share code, notes, and snippets.

@bollu
Forked from mcpherrinm/gist:0116cef42d27583bdcde
Created June 13, 2014 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bollu/1bd9ac58f886c5efe865 to your computer and use it in GitHub Desktop.
Save bollu/1bd9ac58f886c5efe865 to your computer and use it in GitHub Desktop.
mm@cereal:~/dytest$ rustc -C prefer-dynamic --crate-type=dylib fooz.rs
mm@cereal:~/dytest$ cat fooz.rs
#[no_mangle]
pub extern "C" fn foo(x: int) {
println!("Cowabunga, {}", x);
}
mm@cereal:~/dytest$ cat test.py
import ctypes
fooz = ctypes.CDLL("/home/mm/dytest/libfooz-afaf02c9-0.0.so")
fooz.foo(3)
mm@cereal:~/dytest$ python test.py
Cowabunga, 3
mm@cereal:~/dytest$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment