Building QEMU on Ubuntu
The composition of this document has been tested using Ubuntu 20.04 and should function properly on versions such as 20.04, 20.10, 21.04, 21.10, and 22.04.
The commands apt
and apt-get
within the text necessitate administrative privileges.
We are actively seeking improvement to make this documentation applicable to more versions.
Obtaining the Source Code of PolyOS QEMU
PolyOS QEMU is a fork of QEMU. Due to technical reasons, we are actively working on transitioning the source code hosting to utilize the Gitee service.
Installing Dependencies
Before embarking on the tasks of construction and compilation, we must ensure that the requisite dependencies for PolyOS QEMU are properly installed.
These encompass the build and compilation toolchain, graphical libraries, and audio libraries.
apt-get install build-essential meson ninja-build pkg-config \
diffutils
python3 python3-venv \
libglib2.0-dev libusb-1.0-0-dev libncursesw5-dev \
libpixman-1-dev libepoxy-dev libv4l-dev libpng-dev \
libsdl2-dev libsdl2-image-dev libgtk-3-dev libgdk-pixbuf2.0-dev \
libasound2-dev libpulse-dev \
libx11-dev
Compiling PolyOS QEMU
We need to generate the Makefile for compiling PolyOS QEMU.
/path/to/polyos-qemu/code/configure --target-list=riscv64-softmmu --enable-sdl --enable-gtk -prefix=$HOME/.local
This will generate a Makefile with GTK, SDL support enabled.
We specify that the target platform is RISC-V 64bit soft emulation by specifying --target-list=riscv64-softmmu
.
The purpose of this is to avoid compiling all target platforms for QEMU, but you can include other platform targets if you need to.
The compilation of PolyOS QEMU is accomplished with a simple execution of make within the root directory of its source code.
make -j$(nproc)
::tip
The -j$(nproc)
flag designates the utilization of multi-threaded compilation, with the number being equivalent to the result of nproc
(i.e., the number of cores in your computer's CPU).
:::
Installing PolyOS QEMU
The installation of PolyOS QEMU can be easily achieved by executing make install
.
make install
qemu-system-riscv64
will be installed within ~/.local/bin.
Should the need arise, you may also choose to add ~/.local/bin to your PATH
environment variable.
cat << EOF >> ~/.bashrc
export PATH=$HOME/.local/bin:$PATH
EOF
source ~/.bashrc