Ubuntu安装

安装

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

1. curl https://sh.rustup.rs -sSf | sh

3. info: downloading installer
4. # 这里如果网速慢,会等很久,请耐心

6. Welcome to Rust!

8. This will download and install the official compiler for the Rust programming language, and its package manager, Cargo.

10. It will add the cargo, rustc, rustup and other commands to Cargo's bin directory, located at:

12. /home/sky/.cargo/bin

14. This path will then be added to your PATH environment variable by modifying the
15. profile file located at:

17. /home/sky/.profile

19. You can uninstall at any time with rustup self uninstall and these changes will
20. be reverted.

22. Current installation options:

24. default host triple: x86_64-unknown-linux-gnu
25. default toolchain: stable
26. modify PATH variable: yes

28. 1) Proceed with installation (default)
29. 2) Customize installation
30. 3) Cancel installation

32. info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
33. 236.7 KiB / 236.7 KiB (100 %)  53.0 KiB/s ETA:   0 s
34. info: latest update on 2017-11-23, rust version 1.22.1 (05e2e1c41 2017-11-22)
35. info: downloading component 'rustc'
36. 38.5 MiB /  38.5 MiB (100 %)  44.8 KiB/s ETA:   0 s
37. info: downloading component 'rust-std'
38. 54.2 MiB /  54.2 MiB (100 %)  32.0 KiB/s ETA:   0 s
39. info: downloading component 'cargo'
40. 3.8 MiB /   3.8 MiB (100 %)  20.0 KiB/s ETA:   0 s
41. info: downloading component 'rust-docs'
42. 4.2 MiB /   4.2 MiB (100 %)  31.3 KiB/s ETA:   0 s
43. info: installing component 'rustc'
44. info: installing component 'rust-std'
45. info: installing component 'cargo'
46. info: installing component 'rust-docs'
47. info: default toolchain set to 'stable'

49. stable installed - rustc 1.22.1 (05e2e1c41 2017-11-22)

51. Rust is installed now. Great!

53. 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.

55. 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