Skip to content

Build errors on Ubuntu 18.04 with GCC 7.5.0 and how to fix them

I followed the "Building QEMU" chapter in https://virtio-fs.gitlab.io/howto-qemu.html to be able to test the virtio-fs device (sharing of directories between the host and the guest VM using pure QEMU).

My system is Ubuntu 18.04 with GCC 7.5.0. I git-cloned https://gitlab.com/virtio-fs/qemu.git. The commit SHA is 32006c66 (the latest as of this writing).

I found two issues:

  • '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 5 error
  • fatal error: seccomp.h: No such file or directory during compilation and undefined reference to 'seccomp_init' during linking

I solved the former issue by adding Wno-error specifiers in the configuration cmd: ../configure --prefix=$PWD --target-list=x86_64-softmmu --extra-cflags="-Wno-error=format-truncation" --extra-cxxflags="-Wno-error=format-truncation". I know there was an attempt to fix this exact issue in commit cbf66977, which added asserts, but at least for my version of GCC, it seems to have no effect. So I had to fall back to explicit downgrading from errors to warnings.

I solved the second issue by installing seccomp-dev: sudo apt install libseccomp-dev. This is a rather obvious error and solution, but still would be nice to mention seccomp-dev as a pre-requisite for building in the https://virtio-fs.gitlab.io/howto-qemu.html documentation.

These are not critical issues, but I hope this helps someone in the future.