info: profile set to 'default' info: default host triple is x86_64-unknown-linux-gnu warning: Updating existing toolchain, profile choice will be ignored info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu' info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'
To get started you may need to restart your current shell. This would reload your PATH environment variable to include Cargo's bin directory ($HOME/.cargo/bin).
To configure your current shell, run: source "$HOME/.cargo/env"
问题在哪
安装 Cargo 后,我们根据文档执行cargo new hello_world,似乎没什么问题。
但是执行构建指令后,问题显然就发生了。这是由于没有安装编译器。(在纯净环境下总是会忘记装编译环境)
1 2 3 4 5 6 7
$ cargo build Compiling hello_world v0.1.0 (/root/hello_world) error: linker `cc` not found | = note: No such file or directory (os error 2)
error: could not compile `hello_world` (bin "hello_world") due to previous error
在Debian环境下,使用APT包管理器安装编译器的简易方式如下
1
$ apt install build-essential
大功告成
构建Rust应用程序。
1 2 3
$ cargo build Compiling hello_world v0.1.0 (/root/hello_world) Finished dev [unoptimized + debuginfo] target(s) in 0.27s
执行应用程序。
1 2 3 4
$ cargo run Finished dev [unoptimized + debuginfo] target(s) in 0.00s Running `target/debug/hello_world` Hello, world!