rustup
時提示“網絡連接失敗”“無法下載組件”或“缺少Python/curl等依賴”。export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
python3
、curl
等基礎工具,Ubuntu下運行:sudo apt-get install python3 curl
~/.rustup
目錄后重新執行安裝命令。source $HOME/.cargo/env
~/.bashrc
(bash)或~/.zshrc
(zsh)文件末尾,保存后運行source ~/.bashrc
。libssl-dev
not found”“pkg-config
not installed”或“無法鏈接動態庫”。build-essential
(包含gcc、make等):sudo apt-get update && sudo apt-get install build-essential
sudo apt-get install libssl-dev pkg-config clang
cargo build
,確認錯誤消失。cargo build
時報“版本沖突”“無法解析依賴”或“緩存損壞”。Cargo.toml
中的依賴版本后,運行cargo update
同步依賴。target
目錄(rm -rf target/
),清除舊編譯文件后重新構建。cargo tree
命令檢查依賴沖突,手動調整Cargo.toml
中的版本要求(如serde = "1.0"
改為serde = "~1.0"
)。sudo apt-get install gcc-arm-linux-gnueabihf
rustup
添加目標平臺,例如ARMv7:rustup target add armv7-unknown-linux-gnueabihf
~/.cargo/config
中指定鏈接器,例如:[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
scp target/armv7-.../debug/hello user@arm:~
),使用ldd
檢查依賴庫是否完整。./target/debug/hello
時提示“Permission denied”。chmod
命令為可執行文件添加權限:chmod +x ./target/debug/hello
./target/debug/hello
即可。feature
not available”或“syntax error”。rustup
更新到最新穩定版:rustup update stable
rustup default nightly
rustc --version
確認更新成功。