无法在 Rust 中编译 CRC 库 include!(concat!(env!("OUT_DIR"), "/crc16_constants.rs"));

Can't compile CRC library in rust include!(concat!(env!("OUT_DIR"), "/crc16_constants.rs"));

我最近发现了一个非常有趣的库,叫做 Exonum,这个库使用的是 CRC library

每次我尝试在Windows 10 中编译简单的测试项目时,我都会收到:

error: couldn't read "C:\Users\XXXXXX\OUTDIR/crc16_constants.rs": The 
system cannot find the file specified. (os error 2)
 --> src\crc16.rs:8:1
  |
8 | include!(concat!(env!("OUT_DIR"), "/crc16_constants.rs"));
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: Could not compile `crc`.

我试过设置 out_dir 但没有用。该库中似乎有 build.rs 文件应该导出该文件,但它在构建之前没有这样做。 有人有同样的问题吗?

编辑 1:

在评论点后我删除了 OUT_DIR 环境变量并更改了源中的字符串似乎仍然存在问题。编译输出如下:

error: environment variable `OUT_DIR` not defined
 --> crc16.rs:8:18
  |
8 | include!(concat!(env!("OUT_DIR"), "\crc16_constants.rs"));
  |                  ^^^^^^^^^^^^^^^

error: couldn't read "0\crc16_constants.rs": The system cannot find the file specified. (os error 2)
 --> crc16.rs:8:1
  |
8 | include!(concat!(env!("OUT_DIR"), "\crc16_constants.rs"));
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: Could not compile `crc`.

正如评论中指出的那样,解决方案是简单地更新 Rust 并检查 PATH 是否有旧的 cargo.exe