RuyiSDK Getting Started Example
Install dependencies
sudo apt update
sudo apt install -y wget tar zstd xz-utils git build-essentialInstall the ruyi package manager (see the official installation guide for other methods)
wget https://mirror.iscas.ac.cn/ruyisdk/ruyi/tags/0.51.0/ruyi-0.51.0.riscv64
chmod +x ./ruyi-0.51.0.riscv64
sudo cp -v ./ruyi-0.51.0.riscv64 /usr/local/bin/ruyiInstall the GCC and LLVM toolchains
ruyi update
ruyi install gnu-ruyisdk llvm-ruyisdkHello World (GCC)
Create and activate the ruyi virtual environment (GCC)
ruyi venv -t toolchain/gnu-ruyisdk manual venv-gnu-ruyisdk
. venv-gnu-ruyisdk/bin/ruyi-activateVerify the GCC version
riscv64-ruyisdk-linux-gnu-gcc -vCompile Hello World (GCC)
cat > hello.c << 'EOF'
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
EOF
riscv64-ruyisdk-linux-gnu-gcc hello.c -o hello-gcc
Run the generated file
./hello-gccUnder normal circumstances, the terminal displays output similar to:
«Ruyi venv-gnu-ruyisdk» ubuntu@ubuntu:~$ ./hello-gcc
Hello, World!
«Ruyi venv-gnu-ruyisdk» ubuntu@ubuntu:~$Exit the ruyi GCC virtual environment
ruyi-deactivateHello World (LLVM)
Create and activate the ruyi virtual environment (LLVM)
ruyi venv -t toolchain/llvm-ruyisdk manual --sysroot-from gnu-ruyisdk venv-llvm-ruyisdk
. venv-llvm-ruyisdk/bin/ruyi-activateVerify the LLVM version
clang -vCompile Hello World (LLVM)
clang hello.c -o hello-llvmRun the generated file:
./hello-llvmUnder normal circumstances, the terminal displays output similar to:
«Ruyi venv-llvm-ruyisdk» ubuntu@ubuntu:~$ ./hello-llvm
Hello, World!
«Ruyi venv-llvm-ruyisdk» ubuntu@ubuntu:~$Exit the ruyi LLVM virtual environment
ruyi-deactivate