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

  • 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).

主站蜘蛛池模板: 房产| 沂水县| 磴口县| 宁化县| 延吉市| 安图县| 海丰县| 江源县| 惠来县| 沛县| 丹巴县| 镇原县| 特克斯县| 遂平县| 长白| 博白县| 庆阳市| 福海县| 佳木斯市| 武汉市| 中方县| 武胜县| 剑川县| 通渭县| 伽师县| 丹东市| 高密市| 凤台县| 静海县| 盐山县| 六安市| 灌南县| 贡嘎县| 大理市| 嵊泗县| 洮南市| 曲水县| 平凉市| 增城市| 临沭县| 东丽区|