Search code examples
rustrust-obsolete

Rust "extern mod std;" fails with "multiple matching crates for `core`"


I started the Rust for Rubyists tutorial and this code has tripped me up:

extern mod std;

#[test]
fn this_tests_code() {
    println("")
}

fn main() {}

Attempting to compile this gives me:

> rustc testing.rs
testing.rs:1:0: 1:0 error: multiple matching crates for `core`
testing.rs:1 extern mod std;
             ^
note: candidates:
note: path: /usr/local/lib/rustc/x86_64-apple-darwin/lib/libcore-c3ca5d77d81b46c1-0.5.dylib
note: meta: name = "core"
note: meta: vers = "0.5"
note: meta: uuid = "c70c24a7-5551-4f73-8e37-380b11d80be8"
note: meta: url = "https://github.com/mozilla/rust/tree/master/src/libcore"
note: path: /usr/local/lib/rustc/x86_64-apple-darwin/lib/libcore-c3ca5d77d81b46c1-0.6.dylib
note: meta: name = "core"
note: meta: vers = "0.6"
note: meta: uuid = "c70c24a7-5551-4f73-8e37-380b11d80be8"
note: meta: url = "https://github.com/mozilla/rust/tree/master/src/libcore"
error: aborting due to previous error

I'm using rustc 0.6. I'm not sure what it's supposed to be doing, so can anyone give me some insights?


Solution

  • You seem to have two versions of libstd installed, 0.5 and 0.6. You should either delete the older one at:

    /usr/local/lib/rustc/x86_64-apple-darwin/lib/libcore-c3ca5d77d81b46c1-0.5.dylib
    

    or be more specific to rust about which library you want to link:

    extern mod std (vers = "0.6");