--static build fails in v5.0 (since 5010cec2bc87dafab39b3913c8ca91f88df9c540) Hi, Since commit 5010cec2bc87dafab39b3913c8ca91f88df9c540, building qemu fails when configured with --static (eg ../configure --target-list=x86_64-softmmu,x86_64-linux-user --enable-debug --static). On ubuntu 16.04, it fails to find -lffi and -lselinux. After I apt-get install libffi-dev libselinux1-dev, the build still fails: ../backends/dbus-vmstate.o: In function `_nocheck__trace_dbus_vmstate_pre_save': /home/christophe.lyon/src/qemu/build-static/backends/trace.h:29: undefined reference to `_TRACE_DBUS_VMSTATE_PRE_SAVE_DSTATE' ../backends/dbus-vmstate.o: In function `_nocheck__trace_dbus_vmstate_post_load': /home/christophe.lyon/src/qemu/build-static/backends/trace.h:52: undefined reference to `_TRACE_DBUS_VMSTATE_POST_LOAD_DSTATE' ../backends/dbus-vmstate.o: In function `_nocheck__trace_dbus_vmstate_loading': /home/christophe.lyon/src/qemu/build-static/backends/trace.h:75: undefined reference to `_TRACE_DBUS_VMSTATE_LOADING_DSTATE' ../backends/dbus-vmstate.o: In function `_nocheck__trace_dbus_vmstate_saving': /home/christophe.lyon/src/qemu/build-static/backends/trace.h:98: undefined reference to `_TRACE_DBUS_VMSTATE_SAVING_DSTATE' collect2: error: ld returned 1 exit status I'm not able to reproduce your problem. Are you able to reproduce the problem if you cleanup your build directory (make distclean)? Right, after a make distclean + configure, I managed to complete the build after installing libffi-dev libselinux1-dev. However, I think there's a bug in configure: it should either complain when these packages are missing, or disable the module that needs them. Without libffi-dev and libselinux1-dev, the build fails with: LINK x86_64-softmmu/qemu-system-x86_64 /usr/bin/ld: cannot find -lselinux /usr/bin/ld: cannot find -lffi Semi-officially, QEMU only aims to support static linking with usermode emulators, not system mode emulators. I'm not sure we make that clear anywhere in the docs, or configure script. We should probably print a warning from configure if using --static in combination with system emulators, that this is an untested scenario and users are responsible for figuring out any problems they hit such as missing libraries at link time. In particular it is a known limitation that the configure checks for pre-requisite libraries only validate existence of the shared libraries, and make no attempt to look for the static variant, and it was decided not to fix that. I think it's largely that many distros ship pkg-config files which are just broken for the static linking case -- so configure tests "does pkg-config say this will work for static linking", and pkg-config says "yes, that will work", and then it doesn't. If you care about trying to get this to be more reliable you'd want to investigate all of these and file bugs upstream with your distro and get them fixed... OK I wasn't aware that static linking was not supported by system emulators, thanks for the heads-up. I've updated our build scripts not to use static link, so you can close this PR unless you want to keep track that configure needs improvements. Thanks. For the record, previous attempt to fix: https://