Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Created November 11, 2013 06:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save anonymous/7408714 to your computer and use it in GitHub Desktop.
Save anonymous/7408714 to your computer and use it in GitHub Desktop.
void foo();
void factory();
struct {
int version;
void *entry_data;
int entry_len;
void *children_data;
int children_len;
void *f;
} _rust_crate_map_toplevel = {
2,
0, 0,
0, 0,
factory
};
int main() {
foo();
return 0;
}
extern mod rustuv;
use std::rt;
use std::rt::rtio::EventLoop;
use std::ptr;
#[no_mangle]
pub extern "C" fn factory() -> ~EventLoop {
rustuv::uvio::new_loop()
}
#[no_mangle]
pub extern "C" fn foo() {
do rt::start(0, ptr::null()) {
println!("hello");
};
}
all: libfoo.dylib bar.c
clang bar.c -o bar -L. -lfoo -Wl,-rpath,`pwd`
libfoo.dylib: foo.rs
rustc --lib foo.rs
ln -nsf libfoo-*.dylib libfoo.dylib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment