Ubuntu安装

安装

安装安装文档,执行curl https://sh.rustup.rs -sSf | sh

  1. curl https://sh.rustup.rs -sSf | sh
  2. info: downloading installer
  3. # 这里如果网速慢,会等很久,请耐心
  4. Welcome to Rust!
  5. This will download and install the official compiler for the Rust programming language, and its package manager, Cargo.
  6. It will add the cargo, rustc, rustup and other commands to Cargo's bin directory, located at:
  7. /home/sky/.cargo/bin
  8. This path will then be added to your PATH environment variable by modifying the
  9. profile file located at:
  10. /home/sky/.profile
  11. You can uninstall at any time with rustup self uninstall and these changes will
  12. be reverted.
  13. Current installation options:
  14. default host triple: x86_64-unknown-linux-gnu
  15. default toolchain: stable
  16. modify PATH variable: yes
  17. 1) Proceed with installation (default)
  18. 2) Customize installation
  19. 3) Cancel installation
  20. info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
  21. 236.7 KiB / 236.7 KiB (100 %) 53.0 KiB/s ETA: 0 s
  22. info: latest update on 2017-11-23, rust version 1.22.1 (05e2e1c41 2017-11-22)
  23. info: downloading component 'rustc'
  24. 38.5 MiB / 38.5 MiB (100 %) 44.8 KiB/s ETA: 0 s
  25. info: downloading component 'rust-std'
  26. 54.2 MiB / 54.2 MiB (100 %) 32.0 KiB/s ETA: 0 s
  27. info: downloading component 'cargo'
  28. 3.8 MiB / 3.8 MiB (100 %) 20.0 KiB/s ETA: 0 s
  29. info: downloading component 'rust-docs'
  30. 4.2 MiB / 4.2 MiB (100 %) 31.3 KiB/s ETA: 0 s
  31. info: installing component 'rustc'
  32. info: installing component 'rust-std'
  33. info: installing component 'cargo'
  34. info: installing component 'rust-docs'
  35. info: default toolchain set to 'stable'
  36. stable installed - rustc 1.22.1 (05e2e1c41 2017-11-22)
  37. Rust is installed now. Great!
  38. To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH environment variable. Next time you log in this will be done automatically.
  39. To configure your current shell run source $HOME/.cargo/env

配置

~/.bashrc文件中增加下列内容:

  1. #rust
  2. export PATH=$HOME/.cargo/bin:$PATH

验证

执行rustc --version

  1. $> rustc --version
  2. rustc 1.22.1 (05e2e1c41 2017-11-22)

安装openssl

如果compile时报错,找不到openssl:

  1. cargo:rerun-if-env-changed=OPENSSL_DIR
  2. run pkg_config fail: "`\"pkg-config\" \"--libs\" \"--cflags\" \"openssl\"` did not exit successfully: exit code: 1\n--- stderr\nPackage openssl was not found in the pkg-config search path.\nPerhaps you should add the directory containing `openssl.pc\'\nto the PKG_CONFIG_PATH environment variable\nNo package \'openssl\' found\n"

执行下列命令即可:

  1. sudo apt-get install pkg-config libssl-dev