Skip to content

Instantly share code, notes, and snippets.

@ric-bianchi
Last active September 24, 2023 03:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ric-bianchi/bc0bd0f1c41e46ea51b0b428fa306b2e to your computer and use it in GitHub Desktop.
Save ric-bianchi/bc0bd0f1c41e46ea51b0b428fa306b2e to your computer and use it in GitHub Desktop.
Install the latest Qt5 (at the time of writing) from sources on Linux. Compiling Qt5 on Centos7 was not straightforward at all: without the right configuration flags, and the related packages installed, the `xcb` plugins was not built at all and all applications based on Qt5 crash with an error of the type `qt.qpa.plugin: Could not find the Qt p…
# Requirements:
# - Make sure you have a recent GCC compiler supporting, at least, C++11
# install dependencies
sudo yum install libxcb libxcb-devel xcb-util xcb-util-devel libxkbcommon-devel libxkbcommon-x11-devel
sudo yum install xcb-util-image-devel xcb-util-keysyms-devel xcb-util-renderutil-devel xcb-util-wm-devel
# install MESA libs if you don't have NVidia drivers installed
#sudo yum install mesa-libGL-devel
# get the code and extract
wget http://download.qt.io/official_releases/qt/5.15/5.15.0/single/qt-everywhere-src-5.15.0.tar.xz
tar -xvf qt-everywhere-src-5.15.0.tar.xz
# out-of-source build
mkdir buildqt5
cd buildqt5
../qt-everywhere-src-5.15.0/configure -opensource -confirm-license -xcb -xcb-xlib -bundled-xcb-xinput
make -j
# Install Qt5. By default, it will be installed under `/usr/local/Qt-5.15.0`.
# (Reconfigure the build with ./configure -prefix=<path> if you want to install it into another folder)
sudo make install
# Now, in order to use the newly installed Qt5, you have to instruct the environemnt to use it.
export PATH=/usr/local/Qt-5.15.0/bin:$PATH # for bash shell
# Test
qmake --version
# You should see:
# QMake version 3.1
# Using Qt version 5.15.0 in /usr/local/Qt-5.15.0/lib
# Notes:
# - if you want to rebuild Qt5, make sure you clean the build folder first (or create a new build folder);
# otherwise, the build is misconfigured and you get compilation errors or missing files in the installation
# (a missing `qmake` from the `/usr/local/Qt-5.15.0/bin` installation folder is a symptom of that...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment