[Rust] Cargo 가이드

KimCookieYa·2023년 5월 12일
0

Rust

목록 보기
2/3

Cargo

  • Cargo(카고)
  • Rust의 빌드 시스템 및 패키지 매니저
  • rust 공식 인스톨러에 함께 설치된다.

설치 확인

cargo --verison

프로젝트 생성

cargo new hello_cargo --bin
cd hello_cargo

프로젝트 구조

  • /hello_cargo
    • /src
      • main.rs
    • Cargo.toml
    • .gitignore

src/main.rs

fn main() {
    println!("Hello, world!");
}
  • println!러스트 매크로이다.
  • println함수이다.

Cargo.toml

  • TOML(Tom's Obvious, Minimal Language)
  • Cargo의 환경설정 포맷
  • [package]: 패키지 환경설정 시작점
  • [dependencies]: 의존성 리스트 시작점
[package]
name = "hello_cargo"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

프로젝트 빌드 및 실행

# 컴파일
cargo build
# 실행
./target/debug/hello_cargo

# 또는
# 컴파일 및 실행
cargo run

# 컴파일 체크: cargo check

profile
무엇이 나를 살아있게 만드는가

0개의 댓글