Cargo 静态编译

git clone --recursive https://github.com/kornelski/pngquant.git

vi ~/.cargo/config.toml


[http]
debug = true
proxy = "127.0.0.1:1080"

1.apt 更新

2.apt install cargo

3.修改源码的Cargo.toml

[source.crates-io]
#registry = "https://code.aliyun.com/rustcc/crates.io-index.git"
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"

apt install musl-tools

apt-get install musl-dev

export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static

 export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup

wget https://cdn.jsdelivr.net/gh/rust-lang-nursery/rustup.rs/rustup-init.sh

sh rustup-init.sh

export PATH="$HOME/.cargo/bin:$PATH"

rustup target add x86_64-unknown-linux-musl

静态编译设置  源码目录/.cargo/config

[target.'cfg(target_os = "linux")']
rustflags = ["-C", "target-feature=+crt-static"]

[target.'cfg(target_os = "windows")']
rustflags = ["-C", "target-feature=+crt-static"]

gcc编译

cargo build --release --target x86_64-unknown-linux-gnu

独立编译

cargo build --release --target x86_64-unknown-linux-musl

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值