我对生锈的项目有问题,我的lib.rs只有这个
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未知-未知-释放-我得到这个错误:
错误:链接器
ccnot file = note:没有这样的文件或目录(os错误2)
错误:由于先前的错误,无法编译proc-macro2
如果我将proc宏2添加到依赖项中,则错误更改为无法编译.“其他依赖项”,并且在试图将它们添加到Cargo.toml时,它会不断添加新的依赖项。
[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有什么帮助吗?
发布于 2022-04-12 02:07:34
不,你只需要安装:
sudo apt install build-essential编辑(添加更多信息):
Linux安装程序
不检查编译器工具链,但似乎假设您已经安装了一个C链接器!最好的解决办法是安装尝试过的gcc工具链.
How do I fix the Rust error "linker 'cc' not found" for Debian on Windows 10?
发布于 2022-04-11 17:35:55
这是我的WSL ubuntu出了点问题,我的货版不同于windows 1,能够用windows构建它。
https://stackoverflow.com/questions/71831659
复制相似问题