< 返回版块

anli 发表于 2018-01-14 16:50

按照cpython文档,在cargo.toml里引入了cpython库,但编译时报错

error[E0428]: the name `PYTHONSYS_ENV_VAR` is defined multiple times
  --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/cpython-0.1.0/build.rs:10:1
   |
7  | const PYTHONSYS_ENV_VAR: &'static str = "DEP_PYTHON27_PYTHON_FLAGS";
   | -------------------------------------------------------------------- previous definition of the value `PYTHONSYS_ENV_VAR` here
...
10 | const PYTHONSYS_ENV_VAR: &'static str = "DEP_PYTHON3_PYTHON_FLAGS";
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `PYTHONSYS_ENV_VAR` redefined here
   |
   = note: `PYTHONSYS_ENV_VAR` must be defined only once in the value namespace of this module

查看cpython/build.rs文件,发现是使用了条件编译,那为什么条件编译没生效呢?

在qq群经过mike猫大神指点,发现原来是引入库时少加了一个配置项导致

在toml里加入default-features = false就不会报错了


[dependencies.cpython]
version = "0.1"
features = ["extension-module-2-7","python27-sys"]
default-features = false

评论区

写评论

还没有评论

1 共 0 条评论, 1 页