Skip to content

Building from source

Chih-Hsuan Yen edited this page Apr 18, 2022 · 56 revisions

Introduction

While using precompiled binary packages will be appropriate most of the time compiling from sources may very well make sense, too, e. g. to run latest development versions if these aren't available on a particular operating system. So here's a guide how to achieve this.

If running latest development snapshots is your intent please note that these can be compiled in a very convenient way on Arch Linux using its AUR and that corresponding repositories exist in Debian and openSUSE as well, see Binary packages.

We'll try to be verbose yet basic knowledge about working on the shell, package management and how to compile using CMake and GNU make is needed. You may just want to give it a try.
The descriptions stated below should work on any operating system of the *ix ecosystem, that is on all current Linux distributions as well as on BSD. For now distinct packages of Arch Linux, Debian / Ubuntu, Fedora and openSUSE are stated only. Additional distributions may be added.

As for Debian to build the current release 0.16.x Debian version 11 ("bullseye") is mandatory.

Prerequisites

Before compiling it is strongly recommended to remove any preexisting LXQt and associated components which were installed other than according to this guide (updating by following the guide once more hasn't been thoroughly tested yet but should work without issues).

Next we need to install the dependencies to compile LXQt. These are the build environment as well as the various components needed by the software we are going to compile.

Build environment

A CMake version ≥ 3.1.0 is required, see documentation of your distribution.

Arch Linux

pacman --needed -S base-devel cmake git pkgconf

Debian, Derivates

apt install build-essential cmake git

Fedora

dnf group install c-development
dnf install cmake git

openSUSE

zypper install -t pattern devel_basis
zypper install cmake git

Qt

Qt version ≥5.15 is required. This requirement is met by nearly all major Linux distributions so building Qt from source is hardly ever needed any more. On the other hand compiling Qt from its sources isn't exactly a trivial task and not within the scope of this document.
So if you need to compile Qt you may want to look into the various sources addressing this topic (and optionally tell us about your experience).

Arch Linux

pacman --needed -S qt5-base qt5-svg qt5-tools qt5-x11extras

Debian, Derivates

apt install qtbase5-private-dev libqt5svg5-dev qttools5-dev libqt5x11extras5-dev libpolkit-qt5-1-dev

Fedora

dnf install qt5-qtbase-devel qt5-qtsvg-devel qt5-qttools-devel qt5-qtx11extras-devel

openSUSE

zypper install libqt5-qtbase-private-headers-devel libqt5-qtsvg-devel libqt5-qttools-devel libqt5-qtx11extras-devel

KDE components (Frameworks, KScreen)

Arch Linux

pacman --needed -S kguiaddons libkscreen kidletime kwindowsystem solid

Debian, Derivates

apt-get install libkf5guiaddons-dev libkf5idletime-dev libkf5screen-dev libkf5windowsystem-dev libkf5solid-dev

Fedora

dnf install kf5-kguiaddons-devel libkscreen-qt5-devel kf5-kidletime-devel kf5-kwindowsystem-devel kf5-solid-devel

openSUSE

zypper install kguiaddons-devel libkscreen2-devel kidletime-devel kwindowsystem-devel solid-devel

Miscellaneous

Arch Linux

pacman --needed -S bash libstatgrab alsa-lib libpulse lm_sensors libconfig muparser upower polkit-qt5 sudo xorg-xmessage libxss libxcursor libxcomposite libxcb libxkbcommon-x11 libdbusmenu-qt5 libfm menu-cache lxmenu-data gtk-update-icon-cache hicolor-icon-theme xdg-utils xdg-user-dirs oxygen-icons openbox libxslt

Debian, Derivates (Ubuntu see below)

apt install bash libstatgrab-dev libudev-dev libasound2-dev libpulse-dev libsensors4-dev libconfig-dev libmuparser-dev libupower-glib-dev libpolkit-agent-1-dev libpolkit-qt5-1-dev sudo libexif-dev x11-utils libxss-dev libxcursor-dev libxcomposite-dev libxcb-composite0-dev libxcb-damage0-dev libxcb-dpms0-dev libxcb-image0-dev libxcb-screensaver0-dev libxcb-util0-dev libxkbcommon-x11-dev libdbusmenu-qt5-dev libfm-dev libmenu-cache-dev lxmenu-data gtk-update-icon-cache hicolor-icon-theme xdg-utils xdg-user-dirs oxygen-icon-theme openbox-dev libxi-dev xserver-xorg-input-libinput-dev libxcb-randr0-dev libxdamage-dev libjson-glib-dev libx11-xcb-dev libjson-glib-dev libprocps-dev libxtst-dev

Ubuntu

Same as Debian but replace gtk-update-icon-cache with libgtk2.0-bin.

Fedora

dnf install systemd-devel bash libstatgrab-devel alsa-lib-devel pulseaudio-libs-devel lm_sensors-devel libconfig-devel muParser-devel upower-devel polkit-devel polkit-qt5-1-devel sudo libexif-devel xorg-x11-apps libSM-devel libXScrnSaver-devel libXcursor-devel libXcomposite-devel libxcb-devel xcb-util-devel libxkbcommon-x11-devel dbusmenu-qt5-devel libfm-devel menu-cache-devel lxmenu-data gtk-update-icon-cache hicolor-icon-theme xdg-utils xdg-user-dirs oxygen-icon-theme openbox openbox-devel libxslt-devel

openSUSE

zypper install bash libstatgrab-devel alsa-devel libpulse-devel libsensors4-devel libconfig-devel muparser-devel libupower-glib-devel libpolkit-qt5-1-devel sudo libexif-devel xmessage libXss-devel libXcursor-devel libXcomposite-devel libxcb-devel xcb-util-devel libxkbcommon-x11-devel libdbusmenu-qt5-devel libfm-devel menu-cache-devel lxmenu-data gtk3-tools hicolor-icon-theme xdg-utils xdg-user-dirs oxygen5-icon-theme openbox-devel libxslt-devel

Compiling

General/Build Order

In order to meet all mutual dependencies the various components have to be compiled in a particular order which is summed up below.

0

I

II

III

IV

V

These groups must be processed in this order but the order of components within the each group does not matter.

All components are compiled using CMake and GNU make.
It is strongly advised to do the builds out of source tree.
At least on some operating systems like Arch Linux and Debian LXQt doesn't seem to start when CMake variable CMAKE_INSTALL_PREFIX which is explained below is not set to /usr which is something we may have to investigate. On the other hand this assignment will hardly ever do harm so it should be safe to recommend setting /usr in general for now.

Compiling all components individually

The repositories of all components maintained by the LXQt project as well as nearly all othes stated above come with a file README.md providing information how to install the respective component.
This information applies to compiling the archive files of regular releases as well.
The names of all components in the synopsis above are links to those repositories you may just follow.

The general approach is something like

mkdir build
cd build
cmake <path to sources> -DCMAKE_INSTALL_PREFIX=/usr
make
make install

Directory build should be outside the directory of the sources. cmake and make can and should be run by regular users, make install requires root privileges in order to write to the FHS. These can be acquired by sudo. This is depicted in section Scripts to build in one step and mandates an invocation sudo make install. But when all components are compiled on their own its probably more convenient to open an additional root session and invoke make install there.

Scripts to build in one step

Aside from hosting the main issue tracker repository lxqt provides some scripts to compile latest checkouts of the Git master development branch of all components in one step.
By default this repository does not contain any source code. Rather, source code is pulled by Git submodules, see below.

Script build_all_autotools_projects.sh is covering all components where code is configured by the autotools, build_all_cmake_projects.sh those where it is configured by CMake, build_all.sh is just sourcing the other two.
The only components relying on autotools are libfm and libfm-extra of LXDE which are needed by LXQt, too. But by now its' safe to use the precompiled packages providing theses libraries. This was reflected by stating them as prerequisite and means we'll only have to run build_all_cmake_projects.sh. If you do want to compile libfm and libfm-extra from the sources as well you have to uninstall the binary packages providing them as file conflicts will result otherwise.

To install the software after building the scripts will acquire root permissions via sudo. It belongs to the Prerequisites anyway but may need some configuration depending on the defaults of the various systems.
On Arch Linux, Debian and Fedora regular users are not allowed to run make or just make install which is the invocation that matters here. So a line like

<user> ALL=/usr/bin/make

where <user> is placeholder of the system user's name should be added to /etc/sudoers. On Ubuntu regular users are allowed to run make due to their membership in group sudo. On openSUSE Tumbleweed permission to run make install can be acquired by stating the root password.
That aside adding a line like

Defaults timestamp_timeout=30

to /etc/sudoers can make sense as well. It extends the validity of the sudo permissions and can hence prevent the need to file the password several times on not so fast systems.

First we have to prepare a local checkout of repository and source code by running git on the command line.
We'll start by cloning

git clone https://github.com/lxqt/lxqt.git

The repository is using Git submodules to include the actual source code. So next we acquire the sources by running

cd lxqt
git submodule init
git submodule update --remote --rebase

It is strongly recommended to make a backup of directory lxqt prepared that way so as to avoid repeating this procedure should something go wrong.

The scripts support several environment variables, see explanation in the scripts' headers. The most important ones are

  • LXQT_PREFIX: Base directory relative to which LXQt is installed. Points to /usr/local by default and should be set to /usr. Technically it is corresponding with CMake variable CMAKE_INSTALL_PREFIX.
  • LIB_SUFFIX: Path relative to LXQT_PREFIX libraries are stored in. Can be used to adjust the path to habits of Linux distributions where different paths like /usr/lib, /usr/lib64 or /usr/lib/x86_64-linux-gnu can be found. Technically it is corresponding with CMake variable CMAKE_LIB_SUFFIX.
    Should only be set when the auto-detected default doesn't work as expected.

So finally we can launch by running

LXQT_PREFIX=/usr ./build_all_cmake_projects.sh