7

I'm trying to use BigUints from the num crate in Rust, and I'm using this code to import them:

extern crate num;

use num::bigint::BigUint;

However, it returns the following error when I compile:

main.rs:1:1: 1:18 error: can't find crate for `num`
main.rs:1 extern crate num;
      ^~~~~~~~~~~~~~~~~
error: aborting due to previous error

I'm not using any compiler flags.

What am I doing wrong?

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Tyler
  • 486
  • 1
  • 6
  • 20

1 Answers1

12

I'm not using any compiler flags.

If you're using just rustc, then you'll need to use flags to grab the num crate

$ rustc foo.rs --extern num=/path/to/num.rlib

should do it, I think. Of course, you'll have to get a copy of the num crate: https://crates.io/crates/num links to https://github.com/rust-lang/num .

If you use Cargo, you can just add

num = "*"

To the [dependencies] section of Cargo.toml and you'll be good to go.

Steve Klabnik
  • 14,521
  • 4
  • 58
  • 99
  • It’s also possible to use the `-L` flag with `rustc`: `$ rustc foo.rs -L /path/to/libs/` – Pablo Nov 01 '15 at 23:25