Qt Creator, Ubuntu, and VirtualBox

Mar 21, 2017

It is common for IT companies (at least in Germany, automotive field) to use Ubuntu Linux LTS
in a VirtualBox on Windows or Mac hosts. This way the employee can use Microsoft Outlook / Office,
Microsoft Skype, Cisco Spark, or other proprietary collaboration tools, and at the same
time use the supplied virtual machine for development.

By default VirtualBox doesn’t configure any 3D acceleration or multi-core CPU for the guest.
One needs to change these settings in order to have a more responsive desktop environment
and to compile faster Also important not to forget about the installation of the VirtualBox
Guest Additions.

Running glxinfo on a Ubuntu Linux 16.04 LTS in VirtualBox 5.1.18 gives back this information:

If you do a web search after “Qt Creator VirtualBox crash” you will find out how to fix
this problem – either disabling the welcome plug-in, or disable the 3D acceleration of
your VirtualBox.

Disabling the 3D acceleration means that the system will use a software OpenGL driver.

But then again why not simply use a software OpenGL driver just for Qt Creator and
not for the whole system?

Qt Creator ships on Windows with a software OpenGL driver you can find it under
Qt Creator’s bin directory and it’s named opengl32sw.dll. If you rename the file
to opengl32.dll you will force Qt Creator to use the software OpenGL driver.

What about Linux? Unfortunately Qt Creator doesn’t ship the equivalent OpenGL driver,
so you will have to build it yourself, or download the precompiled binaries that
I will provide at the end of the article.

If you look at Mesa 3D’s llvmpipe page you will
see how easy it is to build the software driver:

Install the prerequisites sudo apt install g++ scons llvm-dev

Get the source code wget https://mesa.freedesktop.org/archive/mesa-17.0.2.tar.xz

And compile with scons build=release libgl-xlib

This is true if you have all the prerequisites! If you don’t have them, then it’s a process
of compile, break on error, install missing package, and then try again.