Otu esi etinye Rust na Ubuntu 20.04

nchara na- bụ asụsụ mmemme mepere emepe nke na-elekwasị anya na ọsọ, nchekwa nchekwa, na myirịta. Ndị mmepe na-eji nchara mepụta ọtụtụ ngwa sọftụwia ọhụrụ, dị ka injin egwuregwu, sistemu arụ ọrụ, sistemu faịlụ, ihe nchọgharị, na injin simulation maka eziokwu mebere. Nchara yiri C++ n'ụzọ ọ bụla mana ọ nwere ike ịkwado nchekwa ebe nchekwa site na iji ihe nrịba ego maka ịkwado ntụnyere aka.

Maka ndị ọrụ yana ọkachasị ndị mmepe chọrọ ịnwale asụsụ Rust Programming, na njedebe nke ntuziaka a, ị ga-ama Otu esi etinye Rust na Ubuntu 20.04 LTS. Otu ụkpụrụ ahụ ga-arụ ọrụ maka ụdị ọhụrụ Ubuntu 21.04 (Hirsute Hippo).

Prerequisites

  • OS akwadoro: Ubuntu 20.04 - nhọrọ (Ubuntu 21.04 na Linux Mint 20)
  • Akaụntụ onye ọrụ: Akaụntụ onye ọrụ nwere sudo ma ọ bụ ohere mgbọrọgwụ.
  • Ngwungwu achọrọ: wuo-dị mkpa, curl, gcc na mee.

Nke mbu, gbaa mbọ hụ na emelitere sistemụ arụmọrụ Ubuntu gị ruo taa:

sudo apt update && sudo apt upgrade -y

Na-esote, wụnye ngwugwu achọrọ nke achọrọ n'oge ntinye nke Rust:

sudo apt install curl build-essential gcc make -y

Advertisement


Wụnye Rust na Ubuntu 20.04

Ozugbo ịmechara ntinye nke ngwugwu achọrọ na ihe ndị a chọrọ, ị nwere ike iji ugbu a (curl) ka ibudata edemede nrụnye Rust site na ime iwu a:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Ị ga-ahụ mmepụta dị ka ihe atụ n'okpuru. Pịnye 1 wee pịa Tinye ka ịga n'ihu.

Otu esi etinye nchara na ubuntu 20.04

Nrụnye niile kwesịrị iwere n'etiti nkeji 1 ruo 5, dabere na ọsọ ịntanetị na ngwaike nke sava gị. Ozugbo emechara, ị ga-ahụ nsonaazụ ndị a:

Otu esi etinye nchara na ubuntu 20.04

Nyochaa ụdị arụrụ arụrụ nchara, nke ga-egosikwa gị na etinyere ya nke ọma. Pịnye iwu a wee pịa tinye:

rustc --version

Mmepụta ihe atụ (Nke a ga-agbanwe n'oge na ụdị ọhụrụ):

Otu esi etinye nchara na ubuntu 20.04

Mara, ị ga-achọ ka ịgbalite ya (Gburugburu nchara) maka shei gị ugbu a. A na-eme nke a site na iji iwu na-esonụ iji mee ka gburugburu nchara rụọ ọrụ:

source ~/.profile
source ~/.cargo/env

Mepụta ngwa ihe nlele nchara

Yabụ ị tinyela nchara ma kwenye na ọ kwesịrị ịdị na-arụ ọrụ nke ọma. Mgbe ị na-etinye asụsụ mmemme na sistemụ arụmọrụ gị, ụzọ kachasị mma iji nyochaa bụ ịmepụta ngwa ule ngwa ngwa. Maka ntuziaka, ị ga-emepụta ndị ama ama (Ndewo Ụwa) mmepụta na-eji nchara.

Mbụ, ịkwesịrị ịmepụta ndekọ nke ga-eje ozi dị ka a (Oghere ọrụ):

mkdir ~/rust-projects

Nke abuo, gbanwee ndekọ aha na Workspace wee mepụta ngwa nlele na iwu a:

cd rust-projects && nano helloworld.rs

Ọzọ, tinye koodu a maka ule ndewo ụwa:

fn main() {
    println!("Hello World, this is a test provided by LinuxCapable.com");
}

Zọpụta ma mechie (CTRL+O) wee pụọ (CTRL+X) wee chịkọta mmemme na iwu a:

rustc helloworld.rs

Nke a ga-emepụta ngwa nwere ike ime ka ọ chịkọtachara. Ngwa a ga-adị na ndekọ ndekọ aha gị ugbu a dị ka ihe atụ dị n'okpuru:

Otu esi etinye nchara na ubuntu 20.04

Iji mee ngwa ị mepụtara site na iji Rust, mee usoro ihe omume ahụ na-eme iwu:

./helloworld

Ihe atụ sitere na ngwa ule dị ka n'okpuru:

Otu esi etinye nchara na ubuntu 20.04

Advertisement


Otu esi emelite Rust na Ubuntu 20.04

Imelite Rust dị mfe ma jiri iwu dị mfe mee ya na ọdụ gị. Tinye ihe ndị a:

rustup update

Ihe atụ mmepụta:

Otu esi etinye nchara na ubuntu 20.04

Otu esi ewepu (wepụ) nchara

Ọ bụrụ n'ọdịniihu ị chọghịkwa Rust na sistemụ arụmọrụ Ubuntu gị, mee iwu a:

rustup self uninstall

Ihe atụ mmepụta:

Otu esi etinye nchara na ubuntu 20.04

Iji wepụ ụdị nke ọma (NA) wee pịa igodo ntinye. Ị ga-enweta nsonaazụ a na-ewepụ Rust nke ọma na sistemụ Ubuntu gị:

Otu esi etinye nchara na ubuntu 20.04

Advertisement


Okwu na mmechi

N'ime ntuziaka ahụ, ị ​​mụtala otu esi etinye asụsụ mmemme Rust na Ubuntu 20.04 yana otu esi emepụta ngwa nnwale bụ isi.

N'ozuzu, nchara dị egwu, karịsịa na ọ na-ekwe nkwa nchekwa nchekwa. Ị nweghị ike ide ihe njupụta njupụta, ihe nrịbama na-akụda mmụọ, ma ọ bụ ahụhụ na-enweghị okpukpu abụọ na Rust nke, kama C/C++, na-ewepụ otu klas nchekwa nchekwa na ngwanrọ gị.

Ahapụ a Comment