Preparing Compilation Environment

To prepare a compilation environment, perform the following steps:

Steps:
  1. Visit this link and download the latest version of riscv64-unknown-elf-toolchain-xxx according to your operating system.
  2. Unzip the downloaded toolchain by typing the following:
    tar -xzvf <Toolchain_Name>
    Tip: <Toolchain_Name> refers to the name of the downloaded toolchain in the previous step. For example, riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz.
  3. Open .bashrc file by typing the following:
    gedit ~/.bashrc
  4. Add the following line, save and exit:
    export PATH=$PATH:<Unzipped_Compiler_Path>/bin
    Tip: <Unzipped_Compiler_Path> refers to the location of the unzipped compiler. For example, /home/yingpeng/Downloads/riscv64-unknown-elf-toolchain-xxx/.

    Example:

    export PATH=$PATH:/home/yingpeng/Downloads/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin
  5. Type the following to make the change effective:
    source ~/.bashrc

    Command Example and Result:

    The following figure shows an example command and the result:

    Figure 1. Example Output
    en_effective.png