QT5 on Ubuntu 10LTS

After installing QT5 on an Ubuntu 10.04LTS system I got the following error message:

$ /opt/Qt/Tools/QtCreator/bin/qtcreator
This application failed to start because it could not find or load the Qt platform plugin "xcb".

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, xcb.

Reinstalling the application may fix this problem.

I then found a plugins folder and used ldd -d to try to load the likely plugin:

$ ldd -d ./Tools/QtCreator/bin/plugins/platforms/libqxcb.so
        linux-gate.so.1 =>  (0xb7774000)
        libX11-xcb.so.1 => not found
        libXi.so.6 => /usr/lib/libXi.so.6 (0xb7625000)
        libSM.so.6 => /usr/lib/libSM.so.6 (0xb761b000)
        libICE.so.6 => /usr/lib/libICE.so.6 (0xb7602000)
        libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb75fe000)
        libxcb.so.1 => /usr/lib/libxcb.so.1 (0xb75e4000)
        libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0xb75b4000)
        libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0xb753d000)
        libglib-2.0.so.0 => /lib/libglib-2.0.so.0 (0xb7473000)
        libXrender.so.1 => /usr/lib/libXrender.so.1 (0xb7469000)
        libX11.so.6 => /usr/lib/libX11.so.6 (0xb734c000)
        libQt5DBus.so.5 => /opt/Qt/./Tools/QtCreator/bin/plugins/platforms/../../../lib/qtcreator/libQt5DBus.so.5 (0xb72c3000)
        libQt5Gui.so.5 => /opt/Qt/./Tools/QtCreator/bin/plugins/platforms/../../../lib/qtcreator/libQt5Gui.so.5 (0xb6d81000)
        libQt5Core.so.5 => /opt/Qt/./Tools/QtCreator/bin/plugins/platforms/../../../lib/qtcreator/libQt5Core.so.5 (0xb6845000)
        libGL.so.1 => /usr/lib/mesa/libGL.so.1 (0xb67e0000)
        libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb67c7000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb66d2000)
        libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb66ac000)
        libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb6549000)
        libXext.so.6 => /usr/lib/libXext.so.6 (0xb6539000)
        libuuid.so.1 => /lib/libuuid.so.1 (0xb6534000)
        /lib/ld-linux.so.2 (0xb7775000)
        libXau.so.6 => /usr/lib/libXau.so.6 (0xb6530000)
        libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0xb652a000)
        libz.so.1 => /lib/libz.so.1 (0xb6514000)
        libexpat.so.1 => /lib/libexpat.so.1 (0xb64ec000)
        libpcre.so.3 => /lib/libpcre.so.3 (0xb64bb000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb649c000)
        libicui18n.so.52 => /opt/Qt/./Tools/QtCreator/bin/plugins/platforms/../../../lib/qtcreator/./libicui18n.so.52 (0xb6271000)
        libicuuc.so.52 => /opt/Qt/./Tools/QtCreator/bin/plugins/platforms/../../../lib/qtcreator/./libicuuc.so.52 (0xb60f5000)
        libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0xb60ef000)
        librt.so.1 => /lib/tls/i686/cmov/librt.so.1 (0xb60e6000)
        libXxf86vm.so.1 => /usr/lib/libXxf86vm.so.1 (0xb60e0000)
        libXdamage.so.1 => /usr/lib/libXdamage.so.1 (0xb60db000)
        libXfixes.so.3 => /usr/lib/libXfixes.so.3 (0xb60d5000)
        libdrm.so.2 => /lib/libdrm.so.2 (0xb60ca000)
        libicudata.so.52 => /opt/Qt/./Tools/QtCreator/bin/plugins/platforms/../../../lib/qtcreator/././libicudata.so.52 (0xb4a5e000)

Notice that Lib X11 XCB is missing. The apt-file utility (not installed by default; use the usual apt-get install apt-file command to install it,) can build and search a list of all files in all packages. Using apt-file I got a list of packages that contain the desired file:

$ sudo apt-file find libX11-xcb.so.1
libx11-xcb1: /usr/lib/libX11-xcb.so.1
libx11-xcb1: /usr/lib/libX11-xcb.so.1.0.0
libx11-xcb1-dbg: /usr/lib/debug/usr/lib/libX11-xcb.so.1.0.0

$ sudo apt-get install libx11-xcb1

The next attempt at running QT Creator resulted in another library problem:

$ /opt/Qt/Tools/QtCreator/bin/qtcreator
Failed to load core: /opt/Qt/Tools/QtCreator/lib/qtcreator/plugins/libCore.so: Cannot load library /opt/Qt/Tools/QtCreator/lib/qtcreator/plugins/libCore.so: (/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by /opt/Qt/Tools/QtCreator/lib/qtcreator/plugins/libCore.so))

This time the problem was not a missing file. The requested Lib STDC++ shared object file is actually a symlink:

$ ls -lha /usr/lib/libstdc++.so.6
... /usr/lib/libstdc++.so.6 -> libstdc++.so.6.0.13

In this case the QT package is newer than CentOS5 so we want a newer version of the Standard C++ library as the QT Lib Core plugin is choking on the one provided in the system. A quick search of this specific system finds a more recent copy of libstdc++.so in a NoMachine NX folder:

$ locate libstdc++

Copying that file to /usr/lib and symlinking to it from libstdc++.so.6 solves the problem with QT Creator:

$ sudo cp /usr/NX/lib/libstdc++.so.6.0.17 /usr/lib/
$ sudo ln -sf /usr/lib/libstdc++.so.6.0.17 /usr/lib/libstdc++.so.6

As you can imagine this is not a conveniently repeatable solution as NoMachine may not be available on a different system. Searching again with apt-file reveals another possibility:

$ sudo apt-file search libstdc++.so
gcc-snapshot: /usr/lib/gcc-snapshot/lib/debug/libstdc++.so
gcc-snapshot: /usr/lib/gcc-snapshot/lib/debug/libstdc++.so.6
gcc-snapshot: /usr/lib/gcc-snapshot/lib/debug/libstdc++.so.6.0.14
gcc-snapshot: /usr/lib/gcc-snapshot/lib/libstdc++.so
gcc-snapshot: /usr/lib/gcc-snapshot/lib/libstdc++.so.6
gcc-snapshot: /usr/lib/gcc-snapshot/lib/libstdc++.so.6.0.14
gcc-snapshot: /usr/lib/gcc-snapshot/lib/libstdc++.so.6.0.14-gdb.py

Unfortunately trying to install gcc-snapshot involves over 400mb of dependencies - so it's easier to just extract the desired file to try it:

$ mkdir tmp; cd tmp
$ sudo aptitude download gcc-snapshot
$ dpkg-deb -x gcc-snapshot_20100414-0ubuntu1_i386.deb .
$ find | grep libstd
$ sudo cp -av ./usr/lib/gcc-snapshot/lib/libstdc++.so.6.0.14 /usr/lib/
`./usr/lib/gcc-snapshot/lib/libstdc++.so.6.0.14' -> `/usr/lib/libstdc++.so.6.0.14'

Happily QT creator works equally well with which should be more readily available when needed.