首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >工作区可选依赖项(std & no_std)

工作区可选依赖项(std & no_std)
EN

Stack Overflow用户
提问于 2022-03-14 13:27:24
回答 1查看 313关注 0票数 0

我正在为我们学校的火箭小组开发一个代码,我有两个程序,一个是闪存机载计算机,另一个是对飞行数据进行数据分析。芯片代码使用no_std,数据分析程序使用stddata-analysis代码将在我的PC上运行,chip代码将在芯片上运行。下面是我的工作区根Cargo.toml和我的项目图:

代码语言:javascript
运行
复制
[workspace]

members = [
    "chip",
    "data-analysis",
]
代码语言:javascript
运行
复制
.
├── Cargo.lock
├── Cargo.toml
├── chip
│   ├── Cargo.toml
│   ├── memory.x
│   ├── openocd.cfg
│   ├── openocd.gdb
│   └── src
│       └── main.rs
├── data-analysis
│   ├── Cargo.toml
│   └── src
│       └── main.rs
├── README.md
└── resources
    ├── 3m.mkd
    ├── data-stm32f103c8t6.pdf
    ├── links.txt
    ├── reference-stm32f103xx.pdf
    ├── schematic-stm32f103c8t6.png
    └── todo.txt

我已经决定使用工作区来组织我的代码。当我试图构建工作区时,会得到以下错误:

代码语言:javascript
运行
复制
error[E0463]: can't find crate for `std`
  |
  = note: the `thumbv7m-none-eabi` target may not support the standard library
  = note: `std` is required by `data_analysis` because it does not declare `#![no_std]`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

当我用cargo build -Zbuild-std编译时,我得到了错误:

代码语言:javascript
运行
复制
error[E0463]: can't find crate for `panic_abort`

error[E0658]: use of unstable library feature 'restricted_std'
  |
  = help: add `#![feature(restricted_std)]` to the crate attributes to enable

然而,我需要的是no_std,而不是restricted_std

我理解所有文件的依赖项都存储在Cargo.lock中,这大概就是它产生此错误的原因。我的问题是,我如何向编译器表示,我需要std用于data_analysis,而不是chip代码?我是否应该仅仅使用一个包含多个二进制文件的包,并在Cargo.toml中使用Cargo.toml

EN

回答 1

Stack Overflow用户

发布于 2022-03-14 16:06:25

看起来,您是在试图用与data_analysis相同的目标来简化chip。我建议只删除根Cargo.toml并编译文件夹中各自的根。您可以制作一个Makefile来轻松地实现自动化。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71468549

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档