Rust Install and Setup

INSTALL install - ์„ค์น˜ ํ›„ ~/.bashrc์— ~/.cargo ์ž๋™ ํ™˜๊ฒฝ ์„ค์ • $ curl https://sh.rustup.rs -sSf | sh -- --help rustup ์—…๋ฐ์ดํŠธ/ ์ œ๊ฑฐ $ rustup update $ rustup self uninstall rustc ์ปดํŒŒ์ผ๋Ÿฌ ๋ฒ„์ „ํ™•์ธ $ rustc --version Hello World $ vim hello_world.rs fn main() { #println!๋Š” ํ•จ์ˆ˜๊ฐ€ ์•„๋‹Œ ๋งคํฌ๋กœ println!("Hello, world!"); } $ rustc hello_world.rs Cargo๋ฅผ ํ†ตํ•œ ๊ฐœ๋ฐœ $ cargo new hello_cargo --bin $ cd hello_cargo $ vim src/main.rs fn main() { println!("Hello, world!"); } ./target/debug/hello_cargo ๋กœ ๋ฐ”์ด๋„ˆ๋ฆฌ ์ƒ์„ฑ $ cargo run # compile and run $ cargo run # run only: source is not changed $ cargo check # compile only no exe file create (rapid compile and test) $ cargo clean # cleanup all object and binary files $ cargo run -- --help #์‹คํ–‰ํŒŒ์ผ ์ธ์ž๋ฅผ ๋ฐ›์•„์„œ ์‹คํ–‰ํ•  ๋•Œ $ cargo build $ cargo build --release (optimize for release) ๋ชจ๋“ˆ์„ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ $ cargo add ansi_term #์ž๋™์œผ๋กœ Cargo.toml์— ๋ชจ๋“ˆ์ด๋ฆ„๊ณผ ๋ฒ„์ „์ด ๋“ฑ๋ก๋œ๋‹ค. $ vim src/main.rs #use ansi_term::xxxx ์„ ๋„ฃ๊ณ  ์ฝ”๋”ฉ $ cargo run Build From Git $ git clone someurl.com/someproject $ cd someproject $ cargo build reference ์ œ์ผ ๊ถ๊ธˆํ•œ ๊ฒƒ์€ ์ „์ฒด์ ์ธ ๊ฐœ๋ฐœ ๋ฐ ๋ฐฐํฌ ๊ณผ์ •์ธ๋ฐ ์•„๋ž˜๊ฐ€ ์•„์ฃผ ์ข‹์Œ https://free-strings.blogspot.com/2017/03/cargo-cargo.html https://rust-cli.github.io/book/tutorial/packaging.html ์•„์ฃผ ํ›Œ๋ฅญํ•œ ์ฟก๋ถ์ด๋‹ค. ๋จผ์ € ๊ธฐ๋ณธ ์˜จ๋ผ์ธ๋ถ์„ ๋ณด๊ณ ์„œ ์ด๊ฒƒ์„ ๊ณต๋ถ€ํ•˜์ž. https://rust-lang-nursery.github.io/rust-cookbook/

2022-08-31 ยท 197 words

Rust Compile์‹œ ์šฉ๋Ÿ‰ ์ค„์ด๊ธฐ

Intro debug > release ์ˆœ์œผ๋กœ ์—„์ฒญ๋‚œ ๋ฐ”์ด๋„ˆ๋ฆฌ ์‚ฌ์ด์ฆˆ๋ฅผ ์ž๋ž‘ํ•œ๋‹ค. ์šฐ์„  ๊ฐœ๋ฐœ๊ณผ ๋””๋ฒ„๊น…์„ ๋ณ‘ํ–‰ํ•œ ํ›„์— ์ตœ์ข… ๋ฆด๋ฆฌ์ฆˆ์‹œ์— ์ ์šฉํ•œ๋‹ค. ๋ฐฉ๋ฒ•์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค. Howto Cargo.toml์— ๋‹ค์Œ์„ ์ถ”๊ฐ€ํ•œ๋‹ค. [profile.release] lto = true codegen-units = 1 opt-level = "z" panic = 'abort' build cargo build --release reference https://www.collabora.com/news-and-blog/blog/2020/04/28/reducing-size-rust-gstreamer-plugin/ https://github.com/johnthagen/min-sized-rust

2022-08-31 ยท 44 words

Rust Programming Language

rust install - ๋Ÿฌ์ŠคํŠธ ์„ค์น˜ rust compile size - ์ปดํŒŒ์ผ ์‚ฌ์ด์ฆˆ ์ค„์ด๊ธฐ

2022-08-23 ยท (updated 2022-08-31) ยท 12 words