Guides/Compiling Jqt/Linux

From J Wiki
Jump to navigation Jump to search
Windows | macOS | Linux

Compiling Jqt on Linux

You can compile your own version of Jqt on Linux, for example to:

  • use a later version of Qt than the distribution.
  • add new functions to Jqt
  • restrict the set of Qt libraries required

Slim versions of Jqt are available from . These binaries remove the functionality for websockets, webengine, qml, multimedia, and opengl, and eliminate the need for the corresponding Qt libraries. By compiling your own Jqt, you can selectively remove one or more of the above functions by editing in the Jqt source.

You will need the usual Linux compiler, e.g. in Debian/Ubuntu install package build-essential. Depending on your system, you may need additional libraries. For example under Debian/Ubuntu, you may need libgl1-mesa-dev (opengl) and libpulse-dev (audio). Check the compile for any errors and install additional libraries as required.

Install the Qt SDK

Get Qt using the Qt Online Installer for Linux. This requires a (free) Qt Account, and allows you to choose the Qt versions to be installed, as well as to update the installation later on.

Browse to Get Qt, select and download the the Open Source installer (or Commercial installer if necessary for your application). Run the Qt Online Installer, which presents a list of Qt versions. You can install anywhere on the machine, for example in /opt/qt.

The official J distribution is based on Qt 5.9.5. In theory you can use any version, but note that some Qt versions may require later versions of other non-Qt files than are available in your distribution, and the compilation will fail. If so, then try using an earlier version of Qt.

For example, on the author's machine running Linux Mint 20 (based on Ubuntu 20.04), the Qt version 5.12.9 worked properly.

The components below should be selected (if available), and any others as required:

Desktop gcc 64-bit
Qt WebEngine

Download latest qtide source

Obtain the latest Jqt source from the Git repository, and install anywhere on your machine, e.g. $HOME/qtide. You can modify the contents of the file qtide/lib/ to selectively remove Jqt functions as needed (how to do so will become obvious from reading the file).

In the qtide source directory create and run a script with contents like:

# run in qtide directory

# set the correct Qt SDK directory:
export QTDIR=/opt/qt/5.12.9/gcc_64

# uncomment this for a slim build:
# export JQTSLIM=1

# other exports defined from QTDIR:
export PATH=$QTDIR/bin:$PATH

# set S to the qtide directory:
S=$(dirname "$(realpath $0)")

cd $S/lib
qmake && make
cd $S/main
qmake && make

The binaries will be in the folder qtide/bin/linux-x86_64/release, and should be copied to your ~bin directory.

After you make changes

If you change the source code, you need to re-make the binaries with your changes. You don't need to rerun qmake; just run make in each directory. You do need to ensure the environment variables shown above are defined correctly.

Calling Jqt

You should set the Qt plugin directory before calling J, e.g. use a script like:

export QT_PLUGIN_PATH=/opt/qt/5.12.9/gcc_64/plugins
cd ~/j902
bin/jqt "$@"