2025::Compiling VirtulBox 7.1.12 on Ubuntu
Install dependency
Qt Online Installer
Download Qt Online Installer to install Qt6(need to login,download link after logging in)
- you have to login during the installation

- Chose “Custom Installation”

- Install all libraries

Packages
sudo apt-get install acpica-tools chrpath doxygen g++-multilib libasound2-dev libcap-dev libcurl4-openssl-dev libidl-dev libopus-dev libpam0g-dev libpulse-dev libsdl1.2-dev libsdl-ttf2.0-dev libssl-dev libvpx-dev libxcursor-dev libxinerama-dev libxml2-dev libxml2-utils libxmu-dev libxrandr-dev make nasm python3-dev python2.7-dev texlive texlive-fonts-extra texlive-latex-extra unzip xsltproc default-jdk libstdc++5 libxslt1-dev linux-kernel-headers makeself mesa-common-dev subversion yasm zlib1g-dev glslang-tools lib32z1 libc6-dev-i386 lib32gcc-s1 xsltproc docbook-xsl libdevmapper-dev pylint python3-psycopg2 python3-willow python3-pippip3 install packaging
VirtualBox
VirtualBox Source Code
Download Source Code from official website, don’t pull it from github, which lacks some files:

Compiling
Though the official build instructions is out dated, it’s still worth a look, Linux build instructions
Run configure
first. Because we want to use the Qt we just installed, we have to specify the path by --with-qt-dir
./configure --disable-hardening --disable-docs --with-qt-dir=/home/nini/Qt/6.9.1/gcc_64/
Then setup the environment by source ./env.sh
. The env.sh won’t set PATH
and LD_LIBRARY_PATH
for us though we supply the path of Qt when configuring, we have to assign them by ourselves.
source ./env.shexport PATH="/home/nini/Qt/6.9.1/gcc_64/:$PATH"export LD_LIBRARY_PATH="/home/nini/Qt/6.9.1/gcc_64/lib:$LD_LIBRARY_PATH"
Compiling
kmk KBUILD_TYPE=debug#or you want a release build but with symbolskmk BUILD_TYPE=release VBOX_DO_STRIP=
If any error occurs during compilation, try disabling guest additions first and then try again, that should solve most issues. You can modify the Config.kmk file or append an option after the kmk command:
kmk KBUILD_TYPE=debug VBOX_WITH_ADDITIONS=
Then compile and setupt the kernel module
cd out/linux.x86/release/bin/src./vboxdrv.sh setup./vboxdrv.sh start
We can run the VirtualBox now.
./VirtualBox
If you’re already in the virtual machine, remeber to enable the nested virtualization. For example, in Hyper-V
Set-VMProcessor -VMName "Ubuntu 22.04 LTS" -ExposeVirtualizationExtensions $true
Original Author: terrynini38514
Original Link: https://blog.terrynini.tw/posts/2025-Compiling-VirtulBox-7-1-12-on-Ubuntu/
Publish at: July 22, 2025 at 08:00:00 (Taiwan Time)
Copyright: This article is licensed under CC BY-NC 4.0