Skip to content

Instantly share code, notes, and snippets.

@eightbitraptor
Created June 19, 2014 21:54
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 eightbitraptor/78ed1ab4b25b55e73416 to your computer and use it in GitHub Desktop.
Save eightbitraptor/78ed1ab4b25b55e73416 to your computer and use it in GitHub Desktop.
I don't understand how linking works I think
#![link_args = "-lkyotocabinet"]
extern crate libc;
use libc::types;
extern {
fn kctime() -> libc::c_double;
}
#[test]
fn test_addition() {
unsafe {
tetsubin::kctime();
}
}
rustc -L /usr/local/Cellar/kyoto-cabinet/1.2.76/lib -L build --out-dir=build main.rs
rustc -L /usr/local/Cellar/kyoto-cabinet/1.2.76/lib -L build --out-dir=build --test test/main_test.rs
error: linking with `cc` failed: exit code: 1
note: cc '-m64' '-L' '/usr/local/Cellar/rust/HEAD/lib/rustlib/x86_64-apple-darwin/lib' '-o' 'build/main_test' 'build/main_test.o' '-lmorestack' '-nodefaultlibs' '-Wl,-dead_strip' '/Users/matthewvalentine-house/code/projects/kyoto-rust/build/libtetsubin-2daa2deb-0.1.rlib' '/usr/local/Cellar/rust/HEAD/lib/rustlib/x86_64-apple-darwin/lib/libtest-a79f950d-0.11.0-pre.rlib' '/usr/local/Cellar/rust/HEAD/lib/rustlib/x86_64-apple-darwin/lib/libnative-1fb5e2c0-0.11.0-pre.rlib' '/usr/local/Cellar/rust/HEAD/lib/rustlib/x86_64-apple-darwin/lib/libregex-77385931-0.11.0-pre.rlib' '/usr/local/Cellar/rust/HEAD/lib/rustlib/x86_64-apple-darwin/lib/libtime-4bb3739b-0.11.0-pre.rlib' '/usr/local/Cellar/rust/HEAD/lib/rustlib/x86_64-apple-darwin/lib/libserialize-0352aab7-0.11.0-pre.rlib' '/usr/local/Cellar/rust/HEAD/lib/rustlib/x86_64-apple-darwin/lib/libterm-4e4945a5-0.11.0-pre.rlib' '/usr/local/Cellar/rust/HEAD/lib/rustlib/x86_64-apple-darwin/lib/liblog-cd053230-0.11.0-pre.rlib' '/usr/local/Cellar/rust/HEAD/lib/rustlib/x86_64-apple-darwin/lib/libgetopts-c94737d1-0.11.0-pre.rlib' '/usr/local/Cellar/rust/HEAD/lib/rustlib/x86_64-apple-darwin/lib/libstd-59beb4f7-0.11.0-pre.rlib' '/usr/local/Cellar/rust/HEAD/lib/rustlib/x86_64-apple-darwin/lib/libsync-305341d2-0.11.0-pre.rlib' '/usr/local/Cellar/rust/HEAD/lib/rustlib/x86_64-apple-darwin/lib/librustrt-d8560cb2-0.11.0-pre.rlib' '/usr/local/Cellar/rust/HEAD/lib/rustlib/x86_64-apple-darwin/lib/libcollections-d412c0c4-0.11.0-pre.rlib' '/usr/local/Cellar/rust/HEAD/lib/rustlib/x86_64-apple-darwin/lib/librand-2ea8f361-0.11.0-pre.rlib' '/usr/local/Cellar/rust/HEAD/lib/rustlib/x86_64-apple-darwin/lib/liballoc-1085c790-0.11.0-pre.rlib' '/usr/local/Cellar/rust/HEAD/lib/rustlib/x86_64-apple-darwin/lib/libcore-c5ed6fb4-0.11.0-pre.rlib' '/usr/local/Cellar/rust/HEAD/lib/rustlib/x86_64-apple-darwin/lib/liblibc-4f9a876d-0.11.0-pre.rlib' '-L' '/usr/local/Cellar/kyoto-cabinet/1.2.76/lib' '-L' 'build' '-L' '/Users/matthewvalentine-house/code/projects/kyoto-rust/.rust' '-L' '/Users/matthewvalentine-house/code/projects/kyoto-rust' '-lSystem' '-lpthread' '-lc' '-lm' '-Wl,-rpath,@loader_path/../../../../../../usr/local/Cellar/rust/HEAD/lib/rustlib/x86_64-apple-darwin/lib' '-Wl,-rpath,/usr/local/Cellar/rust/HEAD/lib/rustlib/x86_64-apple-darwin/lib' '-lcompiler-rt'
note: ld: warning: directory not found for option '-L/Users/matthewvalentine-house/code/projects/kyoto-rust/.rust'
Undefined symbols for architecture x86_64:
"_kctime", referenced from:
test_addition::h82dd098f80802bf6faa::v0.0 in main_test.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: aborting due to previous error
make: *** [testtask] Error 101
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment