官术网_书友最值得收藏!

  • Learning Rust
  • Paul Johnson Vesa Kaihlavirta
  • 172字
  • 2021-07-02 23:07:13

Using Cargo to build and run an application

As we are all able to create directory structures, Cargo is then able to build and execute our source code.

If you look at the source code that comes with this chapter, you will find a directory called app_name. To build this package using Cargo, type the following from a Terminal (or command on Windows) window:

cd app_name 
cargo build app_name  

This will build the source code; finally you will be informed that the compilation has been successful:

Next, we can use Cargo to execute the binary as follows:

cargo run

If everything has worked, you will see something like the following:

As with any sort of utility, it's possible to "daisy-chain" the build and execution into one line, as follows:

cargo build; cargo run  

You may be wondering why the first operation performed was to move into the application structure rather than just type cargo build. This is because Cargo is looking for the Cargo.toml file (remember, this acts as a build script).

主站蜘蛛池模板: 虞城县| 从江县| 行唐县| 华蓥市| 上饶市| 义乌市| 错那县| 东源县| 平泉县| 云和县| 淳化县| 贵南县| 唐河县| 云浮市| 仪征市| 安图县| 耿马| 衡山县| 枣强县| 集安市| 汶上县| 新泰市| 遂平县| 夹江县| 镇坪县| 丰原市| 若尔盖县| 黄冈市| 叶城县| 犍为县| 通山县| 成武县| 泽州县| 留坝县| 宜君县| 呼伦贝尔市| 密山市| 泰宁县| 舟曲县| 洛扎县| 玛纳斯县|