首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >货生成会导致依赖编译错误。

货生成会导致依赖编译错误。
EN

Stack Overflow用户
提问于 2022-04-11 17:01:40
回答 2查看 154关注 0票数 0

我对生锈的项目有问题,我的lib.rs只有这个

代码语言:javascript
复制
use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use near_sdk::{env, near_bindgen};

near_sdk::setup_alloc!();

#[near_bindgen]
#[derive(Default, BorshDeserialize, BorshSerialize)]
pub struct Counter {
    // See more data types at https://doc.rust-lang.org/book/ch03-02-data-types.html
    val: i8, // i8 is signed. unsigned integers are also available: u8, u16, u32, u64, u128
}

#[near_bindgen]
impl Counter {
  
    pub fn get_num(&self) -> i8 {
        return self.val;
    }

        self.val += 1;
        let log_message = format!("Increased number to {}", self.val);
        env::log(log_message.as_bytes());
        after_counter_change();
    }

 
    pub fn decrement(&mut self) {
       
        self.val -= 1;
        let log_message = format!("Decreased number to {}", self.val);
        env::log(log_message.as_bytes());
        after_counter_change();
    }
    pub fn reset(&mut self) {
        self.val = 0;
        // Another way to log is to cast a string into bytes, hence "b" below:
        env::log(b"Reset counter to zero");
    }
}

fn after_counter_change() {
    // show helpful warning that i8 (8-bit signed integer) will overflow above 127 or below -128
    env::log("Make sure you don't overflow, my friend.".as_bytes());
}

当我运行RUSTFLAGS='-C链接-arg=-s‘货物构建-目标是32未知-未知-释放-我得到这个错误:

错误:链接器cc not file = note:没有这样的文件或目录(os错误2)

错误:由于先前的错误,无法编译proc-macro2

如果我将proc宏2添加到依赖项中,则错误更改为无法编译.“其他依赖项”,并且在试图将它们添加到Cargo.toml时,它会不断添加新的依赖项。

代码语言:javascript
复制
[package]
name = "contract"
version = "0.1.0"
authors = ["Near Inc <hello@nearprotocol.com>"]
edition = "2021"

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
near-sdk = "=4.0.0-pre.4"

[profile.release]
codegen-units=1
opt-level = "z"
lto = true
debug = false
panic = "abort"
overflow-checks = true

有什么帮助吗?

EN

回答 2

Stack Overflow用户

发布于 2022-04-12 02:07:34

不,你只需要安装:

代码语言:javascript
复制
sudo apt install build-essential

编辑(添加更多信息):

Linux安装程序

不检查编译器工具链,但似乎假设您已经安装了一个C链接器!最好的解决办法是安装尝试过的gcc工具链.

How do I fix the Rust error "linker 'cc' not found" for Debian on Windows 10?

贷记:https://stackoverflow.com/users/4498831/boiethios

票数 1
EN

Stack Overflow用户

发布于 2022-04-11 17:35:55

这是我的WSL ubuntu出了点问题,我的货版不同于windows 1,能够用windows构建它。

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

https://stackoverflow.com/questions/71831659

复制
相关文章

相似问题

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