【Rust】Rust的安裝和配置

-----------------------參考文檔-------------------------------------html

https://www.rust-lang.org/tools/installvim

https://doc.rust-lang.org/cargo/reference/source-replacement.htmlcurl

---------------------------------------------------------------------工具

本次安裝是在Ubuntu18.04上面進行的測試

概念:ui

  • rustup:安裝rust和管理版本的工具,rust如今還處於發展期,存在三種版本:穩定版、測試版、每夜版;使用rustup能夠在這三個版本中進行切換,默認是穩定版。經過rustup命令能夠安裝rustc、cargo、rustup等標準工具,目錄位於  $HOME/.cargo/bin下。
  • cargo:rust的代碼組織管理工具,提供了一系列的工具來支撐從項目創建、構建到測試、運行直至部署整個流程。
  • rustc:rust語言的編譯器

1.安裝url

運行curl命令下載rustup並運行安裝spa

curl https://sh.rustup.rs -sSf | sh

如命令行中的提示,經過該命令會下載rust的編譯器和包的管理器cargo命令行

若是提示說Rust is installed now.Great! 表示rust已經安裝完成了3d

生效環境變量

source $HOME/.cargo/env

2.驗證安裝

運行rustc查看版本號

rustc --version

3.運行hello_world

建立包和項目的文件夾

mkdir rust_projects
cd rust_projects
mkdir hello_world
cd hello_world
vim main.rs

在main.rs中輸入內容並保存

fn main(){
    println!("hello_world!");
}

使用rustc編譯rs文件

rustc main.rs

編譯完成以後會生成可執行文件

運行main這個可執行文件

./main

 ----------------------------------------------------------

問題解決:

1.error:linker 'cc' not found

這個是由於沒有安裝gcc致使,安裝gcc以後再次編譯便可

安裝gcc

sudo apt-get build-dep gcc
相關文章
相關標籤/搜索