How can I use the 'num' crate in my build.rs?

I'm trying to use the 'num' crate in my build.rs. So following the instructions on the 'num' crate page I have this in my Cargo.toml:

[dependencies]
num = "0.2"

And this in my build.rs:

extern crate num;

The 'num' crate gets downloaded and compiled. However cargo then complains:

error[E0463]: can't find crate for `num`
 --> build.rs:5:1
  |
5 | extern crate num;
  | ^^^^^^^^^^^^^^^^^ can't find crate

Which I find odd as I know this works from a regular main().

What to do?

1 Like

Build dependencies need to go in a seperate section of your Cargo.toml: Specifying Dependencies - The Cargo Book

2 Likes

Thanks. That fixed it.

Like many things Rust, it's all clear when you can find it.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.