zoukankan      html  css  js  c++  java
  • 【Rust】Rust的安装和配置

    -----------------------参考文档-------------------------------------

    https://www.rust-lang.org/tools/install

    https://doc.rust-lang.org/cargo/reference/source-replacement.html

    ---------------------------------------------------------------------

    本次安装是在Ubuntu18.04上面进行的

    概念:

    • rustup:安装rust和管理版本的工具,rust现在还处于发展期,存在三种版本:稳定版、测试版、每夜版;使用rustup可以在这三个版本中进行切换,默认是稳定版。通过rustup命令可以安装rustc、cargo、rustup等标准工具,目录位于  $HOME/.cargo/bin下。
    • cargo:rust的代码组织管理工具,提供了一系列的工具来支撑从项目建立、构建到测试、运行直至部署整个流程。
    • rustc:rust语言的编译器

    1.安装

    运行curl命令下载rustup并运行安装

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

    如命令行中的提示,通过该命令会下载rust的编译器和包的管理器cargo

    如果提示说Rust is installed now.Great! 表示rust已经安装完成了

    生效环境变量

    source $HOME/.cargo/env

    2.验证安装

    运行rustc查看版本号

    rustc --version

    3.运行hello_world

    创建包和项目的文件夹

    mkdir rust_projects
    cd rust_projects
    mkdir hello_world
    cd hello_world
    vim main.rs

    在main.rs中输入内容并保存

    fn main(){
        println!("hello_world!");
    }

    使用rustc编译rs文件

    rustc main.rs

    编译完成之后会生成可执行文件

    运行main这个可执行文件

    ./main

     ----------------------------------------------------------

    问题解决:

    1.error:linker 'cc' not found

    这个是因为没有安装gcc导致,安装gcc之后再次编译即可

    安装gcc

    sudo apt-get build-dep gcc

     

  • 相关阅读:
    无法远程连接mssqlserver2005服务器的解决
    can't init script for
    为什么要分层?
    如何判断控件是否已加载完成
    社团管理_第4组_需求分析报告
    FSF
    【转载】(翻译)反射的第二部分:Emit
    【转载】Emit学习基础篇基本概念介绍
    白话C#
    GCC
  • 原文地址:https://www.cnblogs.com/sunlingC/p/11120315.html
Copyright © 2011-2022 走看看