Monday, 4 January 2016

Installation and verification

For any language to work with, we have to perform set-up. Rust is also not an exception. We have to install Rust to get started with Rust. Now, let's see how we can set-up our environment.

The installation process has several steps,
  1. Download the artefact

    I am using Windows platform and the set-up instructions are mentioned for this platform. So, For Windows platform, you have to browse to this site, Rust Download
    For Widows Rust is supported for 64 bit version only. So, first step before download should be checking your OS architecture. Open command prompt/Powershell and run the following command,
    wmic os get osarchitecture
    

    And you will get similar to the following,
    OSArchitecture
    64-bit
    

    If you get it 32-bit, its time you should upgrade to 64-bit OS. If you are not sure how to do that, please talk to the vendor of your system or get help from your friend who knows about OS Installation.

    Once you have checked the OS version, you should navigate to the website. On the website, we can see there are two options for Windows platform, GNU ABI and MSVC ABI. MSVC ABI. You may get confused at this stage. So, I recommend using the GNU ABI which does not have any other dependencies while the MSVC Builds are dependent on Microsoft Visual Studio. So, for learning purpose, we'll be using the GNU ABI version.

    The website also suggests that, 'Rust's support for the GNU ABI is more mature, and is recommended for typical uses.' So we'll adhere to Rust  recommendation.

    So, download the GNU ABI Version as pointed in the snapshot,

  2. Once the file is downloaded to your system, it should have the name, 'rust-1.5.0-x86_64-pc-windows-gnu.msi'. The name might be different but it surely will have rust and 1.5.0.
  3. Once the file is downloaded, click on it and it will show a window with License of Rust.
  4. Now, you should see a button, 'Install' on the screen and you have to click on the button
  5. Once, you have clicked on the button, you will see the following window,
  6. You have to wait until this gets completed. You may get a warning from Windows. You should click Yes.
  7. Once the installation is completed, you will get to see the following and you can click 'Finish'.
  8. Once you click on 'Finish', the installation is completed and you are good to go with exploring Rust.
  9. Now, you should close all the open command prompt and start with a new command prompt.
  10. In the new command prompt, issue the following command,
    rustc --version
    And you should see the version of Rust Compiler.
At this point, we can tell that the installation is completed. Now let's write a small program to verify if Rust is completely working on your system. Open Notepad/Notepad++ and write the following content on a file and save it with name main.rs,

fn main() {
    println!("Hello, world!");
}

Now, using command prompt, navigate to the location where you have saved main.rs.

On the directory issue the following command,

rustc main.rs

Now if you have typed everything correct, moved to the right directory containing main.rs file and mentioned the right file name, you will see no output and you will get to see another prompt similar to the following,

Now, that's right. After the compilation is completed, you should see another file generated on the same directory with the name main.exe

Now, its time to run the program and check the integrity. Let's run the program using the following command on the command prompt,
main

Now, you will see the following output on the screen,

Hello, world!

Now, that completes the installation and verification of Rust.

You can download the main.rs file from Git, here is the link.


No comments:

Post a Comment