Preparing Compilation Environment
To prepare a compilation environment, perform the following steps:
Steps:- Visit this link and download the latest version of riscv64-unknown-elf-toolchain-xxx according to your operating system.
-
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
. -
Open
.bashrc
file by typing the following:gedit ~/.bashrc
-
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
-
Type the following to make the change effective:
source ~/.bashrc
Command Example and Result:
The following figure shows an example command and the result: