cargo是rust的编译与打包工具,可将rust打包成为一个可执行性文件。生成的可执行性文件不能跨系统的大版本,比如在linux7上打包,那么程序无法在linux6上执行。

# cargo new hello_cargo
Created binary (application) `hello_cargo` package
# cd hello_cargo
# ls
Cargo.toml src
# ll -a
total
drwxr-xr-x root root Jan : .
drwxr-xr-x root root Jan : ..
-rw-r--r-- root root Jan : Cargo.toml
drwxr-xr-x root root Jan : .git
-rw-r--r-- root root Jan : .gitignore
drwxr-xr-x root root Jan : src
# cat Cargo.toml
[package]
name = "hello_cargo"
version = "0.1.0"
authors = ["tanpf <itoracle@163.com>"]
edition = "" [dependencies]
# cd src
# ls
main.rs
# cat main.rs
fn main() {
println!("Hello, world!");
}
[root@itoracle src]# cargo build
Compiling hello_cargo v0.1.0 (/usr/local/automng/src/rust/test/hello_cargo)
Finished dev [unoptimized + debuginfo] target(s) in .05s
[root@itoracle src]# ll
total
-rw-r--r-- root root Jan : main.rs
[root@itoracle hello_cargo]# ./target/debug/hello_cargo
Hello, world!
[root@itoracle hello_cargo]# cargo run
Finished dev [unoptimized + debuginfo] target(s) in .01s
Running `target/debug/hello_cargo`
Hello, world!
[root@itoracle hello_cargo]#
[root@itoracle hello_cargo]#
[root@itoracle hello_cargo]# vim src/main.rs fn main() {
println!("Hello, world!");
println!("过年回家的火车票,为啥每次都抢不到呢");
}

如果修改了代码,cargo run会先编译再运行

[root@itoracle hello_cargo]# cargo run
Compiling hello_cargo v0.1.0 (/usr/local/automng/src/rust/test/hello_cargo)
Finished dev [unoptimized + debuginfo] target(s) in .46s
Running `target/debug/hello_cargo`
Hello, world!
过年回家的火车票,为啥每次都抢不到呢

cargo check进行代码的编译,但不生成可执行文件,速度比cargo build快很多,当代码比较多时,可以先check

[root@itoracle hello_cargo]# cargo check
Checking hello_cargo v0.1.0 (/usr/local/automng/src/rust/test/hello_cargo)
Finished dev [unoptimized + debuginfo] target(s) in .13s

1.2 rust cargo的更多相关文章

  1. rust cargo 一些方便的三方cargo 子命令扩展

    内容来自cargo 的github wiki,记录下,方便使用 可选的列表 cargo-audit - Audit Cargo.lock for crates with security vulner ...

  2. Rust语言之HelloWorld

    Rust语言之HelloWorld 参考文档: http://doc.crates.io/guide.html 1 什么是Cargo 相当于maven/ant之于java, automake之于c, ...

  3. Win7 VSCode 在线安装Rust语言及环境配置

    睡前彻底解决在VSCode中,按F12不跳转到标准库源码的问题. 首先,如果装过离线版,卸载掉. 然后去官网下载 rustup-init.exe https://www.rust-lang.org/t ...

  4. windows平台rust安装

    1.安装目录环境变量 RUSTUP_HOME D:\WorkSoftware\Rust\cargo CARGO_HOME D:\WorkSoftware\Rust\rustup 2.安装下载加速环境变 ...

  5. 不用rustup,Windows下gnu版Rust安装与开发环境配置

    写在前面 本文介绍了在不使用rustup的情况下,在Windows上安装gnu版的Rust,并配置开发环境(VSCode + rust-analyzer,CLion + IntelliJ Rust)的 ...

  6. FinClip小程序+Rust(三):一个加密钱包

    ​ 一个加密货币钱包,主要依赖加密算法构建.这部分逻辑无关iOS还是Android,特别适合用Rust去实现.我们看看如何实现一个生成一个模拟钱包,准备供小程序开发采用 前言 在之前的内容我们介绍了整 ...

  7. Rust学习入门

    介绍 特性: 高性能,内存利用率高,没有运行时和垃圾回收 可靠 , 丰富的类型系统和所有权模型保证内存和线程安全,编译器可以消除各种错误 生产力, 包管理器.构建工具一流, 多编辑器支持自动补齐和格式 ...

  8. ycmd for emacs 代码自动补全

    YCMD FOR EMACS Table of Contents 1. 安装 1.1. 下载 1.2. 安装相关依赖 1.3. 更新submodules 1.4. 安装 2. 配置 1 安装   1. ...

  9. 不一样的go语言-构建系统与构件系统

    前言   代码的最后一步是构建成计算机可识别的二进制数据,然后才得以在计算机上运行.如果你曾经写过有点规模(至少数十个以上独立的源文件,且需要依赖第三方包)C语言项目,必定对C语言项目的构建过程印象深 ...

随机推荐

  1. sequelize 测试

    1.在根目录新建module文件,在文件下新建文件modelhead.js 代码如下: var Sequelize=require("sequelize") var sequeli ...

  2. Luogu 4216 [SCOI2015]情报传递

    BZOJ 4448. 写起来很愉悦的题. 按照时间可持久化线段树,修改就在原来的地方加$1$即可,查询就直接询问$root_1 - root_{now - c - 1}$中相应的个数. 主席树维护树链 ...

  3. 使用Maven搭建SSM框架(Eclipse)

    今天学习一下使用Maven搭建SSM框架,以前都是用别人配置好的框架写代码,今天试试自己配置一下SSM框架. 这里我的参数是Windows7 64位,tomcat9,eclipse-jee-neon- ...

  4. Excel课程学习

    1.Excel软件简介 1.1历史上的其他数据处理软件与Microsoft Excel 1977年,苹果公司开发了一款数据处理软件,当时这款软件卖的非常好,用软件的尾巴摇动硬件的狗,当时有人因为这款软 ...

  5. discuz_ucenter_api_for_java的中文问题

    我踩过的坑,希望你别掉进来. 云服务需要和UCENTER做对接,一个php,一个Java,幸好有了discuz_ucenter_api_for_java,帮我解决了大部分问题,为什么是大部分问题,因为 ...

  6. c# 匿名函数和lamda表达式语法

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  7. 【Arcgis for android】spatialite打开shapefile

    互联网(free and share) 本文参考下面的博文: http://blog.csdn.net/arcgis_all/article/details/8232976 Preparation: ...

  8. VMWare虚拟机无法打开内核设备"\\.\Global\vmx86"的解决方法

    cmd执行: 1.net start vmci 2.net start vmx86 3.net start VMnetuserif

  9. [转]Marshaling a SAFEARRAY of Managed Structures by P/Invoke Part 4.

    1. Introduction. 1.1 In parts 1 through 3 of this series of articles, I have thoroughly discussed th ...

  10. InnoDB记录压缩及使用分析

    此文已由作者温正湖授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 这篇文章,源于RDS组内的一次饭后闲聊,两位小伙伴在探讨InnoDB启用压缩后的种种,比如在磁盘上是怎么存放 ...