1.2 rust cargo
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的更多相关文章
- rust cargo 一些方便的三方cargo 子命令扩展
内容来自cargo 的github wiki,记录下,方便使用 可选的列表 cargo-audit - Audit Cargo.lock for crates with security vulner ...
- Rust语言之HelloWorld
Rust语言之HelloWorld 参考文档: http://doc.crates.io/guide.html 1 什么是Cargo 相当于maven/ant之于java, automake之于c, ...
- Win7 VSCode 在线安装Rust语言及环境配置
睡前彻底解决在VSCode中,按F12不跳转到标准库源码的问题. 首先,如果装过离线版,卸载掉. 然后去官网下载 rustup-init.exe https://www.rust-lang.org/t ...
- windows平台rust安装
1.安装目录环境变量 RUSTUP_HOME D:\WorkSoftware\Rust\cargo CARGO_HOME D:\WorkSoftware\Rust\rustup 2.安装下载加速环境变 ...
- 不用rustup,Windows下gnu版Rust安装与开发环境配置
写在前面 本文介绍了在不使用rustup的情况下,在Windows上安装gnu版的Rust,并配置开发环境(VSCode + rust-analyzer,CLion + IntelliJ Rust)的 ...
- FinClip小程序+Rust(三):一个加密钱包
一个加密货币钱包,主要依赖加密算法构建.这部分逻辑无关iOS还是Android,特别适合用Rust去实现.我们看看如何实现一个生成一个模拟钱包,准备供小程序开发采用 前言 在之前的内容我们介绍了整 ...
- Rust学习入门
介绍 特性: 高性能,内存利用率高,没有运行时和垃圾回收 可靠 , 丰富的类型系统和所有权模型保证内存和线程安全,编译器可以消除各种错误 生产力, 包管理器.构建工具一流, 多编辑器支持自动补齐和格式 ...
- ycmd for emacs 代码自动补全
YCMD FOR EMACS Table of Contents 1. 安装 1.1. 下载 1.2. 安装相关依赖 1.3. 更新submodules 1.4. 安装 2. 配置 1 安装 1. ...
- 不一样的go语言-构建系统与构件系统
前言 代码的最后一步是构建成计算机可识别的二进制数据,然后才得以在计算机上运行.如果你曾经写过有点规模(至少数十个以上独立的源文件,且需要依赖第三方包)C语言项目,必定对C语言项目的构建过程印象深 ...
随机推荐
- 【摘自张宴的"实战:Nginx"】使用nginx的proxy_cache模块替代squid,缓存静态文件
#user nobody;worker_processes 1; error_log logs/static_source.error.log;#error_log logs/error.log no ...
- 面试题:Concurrenthashmap原理分析 有用
一.背景: 线程不安全的HashMap 因为多线程环境下,使用Hashmap进行put操作会引起死循环,导致CPU利用率接近100%,所以在并发情况下不能使用HashMap. 效率低下的H ...
- Centos7安装mysql缺乏yum源怎么安装
找到mysql5.6的centos的repo源,终于解决mysql的安装问题: 1.确保centos安装了wget,没有的话安装wget 1 yum install wget 2.下载mysql的 ...
- VS2013中,将Qt的GUI程序改为控制台程序
在Visual studio 中创建QT GUI程序是不带Console的,但是调试时候常常需要查看打印信息,可以通过如下设置显示控制台 方法一.在vs中直接创建控制台程序方法二.当你通过设置你的应用 ...
- SDUT 2142 数据结构实验之图论二:基于邻接表的广度优先搜索遍历
数据结构实验之图论二:基于邻接表的广度优先搜索遍历 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Descript ...
- labview中的移位寄存器、循环隧道,自动索引隧道的区别
对于循环结构(For 循环.while循环)而言,循环体内的数据域外部数据的传递是通过以下三种方式: 1.移位寄存器2.循环隧道3.自动索引隧道 第一.各自的区别.作用 循环隧道,就是把数据传入传出循 ...
- CodeForces 141C Queue (构造)
题意:n 个人在排队,然后给出每个人的前面比他身高高的人的数量hi,让你给出一种排列,并给出一种解. 析:首先,hi 小的要在前面,所以先进行排序,然后第一个人的 h1 必须为0,我们可以令身高为 1 ...
- oracle-dmp文件导入导出过程命令
创建表空间 create tablespace coss datafile 'D:\soft\db\oracle\oradata\orcl\coss.dbf' size 1000m autoexten ...
- requireJS入门基础
参考 require.js详解 1.引用requireJS的html文件 <!DOCTYPE html> <head> <title>requireJS</ ...
- Ubuntu小记
一. Ubuntu分区记忆 参考教程调整: 1. /boot用于安装grub,设为主分区 2. /根目录20G一般足够 3. /home剩下的给home 4. swap空间=物理内存 挂载点 大小 类 ...