9.1 KiB
Compiling Qt5-Based Open Source Application -- qBittorrent in Linyaps Container
After learning the Basic Knowledge of Linyaps Application Build Projects in the previous chapter, we are about to enter the practical classroom and use the knowledge we have learned to officially build a Linyaps application.
Today, we will demonstrate how to enter the Linyaps container and compile the source code of an open source graphical application qBittorrent into binary files and test its operation.
Preliminary Preparation
According to the requirements in Basic Knowledge of Linyaps Application Build Projects for the Specifications for General Resources in Linyaps Application Build Projects, we should provide both icons icon files and desktop startup files for graphical applications to ensure desktop user experience.
However, this practical classroom will only perform compilation and testing operations in the Linyaps container, so general resources do not need to be prepared temporarily.
This sharing is based on the deepin 23 distribution, so before performing any of the following steps, you need to prepare a deepin 23 system environment that can build Linyaps applications:
-
Ensure that the
ll-builderbuild suite has been installed in the environment. For installation methods on different distributions, please refer to: Install Linyaps -
Since we need to connect to the network to obtain the runtime libraries of the Linyaps container and possibly needed third-party libraries during the build process, we need to ensure smooth network connection throughout the entire operation process
-
Before compiling through the Linyaps container, you had better successfully compiled
qBittorrentindeepin 23which is relatively close to this build container to ensure you have some understanding of the source code compilation -
Combine the [Linyaps Application Build Project
linglong.yamlSpecification] in the previous section and simply write a Linyaps build project configuration filelinglong.yamlaccording to the following template to generate a container that meets the requirements
The main points to note are: * Since this operation directly enters the container for operation, the build rules in the build part do not need to be written in detail * Since this compilation operation is involved, in order to include the required runtime libraries to the greatest extent, we add the runtime section. For specific writing specifications, please refer to [Basic Knowledge of Linyaps Application Build Projects]
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: LGPL-3.0-or-later
version: "4.6.7.2"
package:
id: org.qbittorrent.qBittorrent
name: "qBittorrent"
version: 4.6.7.2
kind: app
description: |
qBittorrent binary
base: org.deepin.foundation/23.0.0
runtime: org.deepin.Runtime/23.0.1
command:
- /opt/apps/org.qbittorrent.qBittorrent/files/bin/qbittorrent
source:
- kind: local
name: "qBittorrent"
build: |
mkdir -p ${PREFIX}/bin/ ${PREFIX}/share/
Project Compilation Demonstration
*Here we need to review a knowledge point: According to [Linyaps Application Directory Structure Specification], the build directory at the same level as the build project configuration file linglong.yaml will be mapped as the /project directory
Everything is ready, we can start compiling
-
For convenience of operation, we open two shell windows in the build directory at the same time, which are used for
Linyaps Container OperationandNormal Operationrespectively -
After completing the preparation of
linglong.yamlediting, we can start generating the container. Execute limited operations to directly enter the Linyaps container:
szbt@szbt-linyaps23:/media/szbt/Data/ll-build/QT/qBittorrent-git$ ll-builder build --exec bash
When the path changes similar to the following, it means we have entered the Linyaps container:
szbt@szbt-linyaps23:/project$
- Extract the
qBittorrent-4.6.7source code to the build directory through theNormal Operationwindow. I extracted it to a subdirectory here separately
szbt@szbt-linyaps23:/media/szbt/Data/ll-build/QT/qBittorrent-git$ tar -xvf qBittorrent-4.6.7-git-origin-src.tar.zst -C src/
-
After the source code is extracted, according to [Basic Steps for Linyaps Application Building], we should correctly choose which compilation system/tools to use before compiling any source code. We observe the
qBittorrent-4.6.7source code directory and can see that it has aCMakeLists.txtfile, which is aCMakebuild project.
-
Since the qBittorrent INSTALL briefly describes the runtime libraries mainly used by this project, we can compare this document to determine which runtime libraries exist in the
baseandruntimeprovided by Linyaps and which runtime libraries are not provided. For runtime libraries that are not officially provided, we may need to pre-compile the necessary third-party libraries before compiling the main program.
Since the runtime libraries described in the document are few, we can directly perform a test compilation this time to confirm the missing runtime libraries
- Without delay, we enter the source code directory through the
Linyaps Container Operationwindow. In order to avoid interference with the source directory as much as possible, I create a newbuilddirectory here for compilation. After entering thebuilddirectory, we enter CMake-related configuration parameters to configure the build project. According to [Linyaps Application Directory Structure Specification], we assign the value ofDCMAKE_INSTALL_PREFIXto$PREFIX. Finally, I executed the following operations locally:
cmake -DCMAKE_BUILD_TYPE=Release\
-DCMAKE_INSTALL_PREFIX=$PREFIX ..
- As can be seen from the figure, an error occurred here that prevented the configuration from being completed. We see that
pkg-confighas an error: thelibtorrent-rasterbar>=1.2.19library cannot meet the conditions:
-- Found PkgConfig: /bin/pkg-config (found version "1.8.1")
-- Checking for module 'libtorrent-rasterbar>=1.2.19'
I also cannot obtain relevant information about this library through pkg-config alone:
szbt@szbt-linyaps23:/project/src/qBittorrent-release-4.6.7-szbt2/build$ pkg-config --print-provides libtorrent-rasterbar
Based on this error, we can basically determine that the library is missing, so we need to compile and install this third-party library before compiling the main program
-
We return to the
Normal Operationwindow and download the source code corresponding to thelibtorrent-rasterbar>=1.2.19library to the current build directory. Enter theLinyaps Container Operationwindow to recompile -
After the source code is extracted, according to [Basic Steps for Linyaps Application Building], we should correctly choose which compilation system/tools to use before compiling any source code. We observe the
libtorrent-rasterbar-2.0.9source code directory and can see that it has aCMakeLists.txtfile, which is aCMakebuild project.
- We enter the source code directory through the
Linyaps Container Operationwindow. In order to avoid interference with the source directory as much as possible, I create a newbuilddirectory here for compilation. After entering thebuilddirectory, we enter CMake-related configuration parameters to configure the build project. According to [Linyaps Application Directory Structure Specification], we assign the value ofDCMAKE_INSTALL_PREFIXto$PREFIX. Finally, I executed the following operations locally:
cmake -DCMAKE_BUILD_TYPE=Release\
-DCMAKE_INSTALL_PREFIX=$PREFIX ..
make -j$(nproc)
make install
As can be seen, the third-party library libtorrent-rasterbar-2.0.9 was successfully compiled and installed into the $PREFIX directory in the container. We can start the next operation
- We return to the
Linyaps Container Operationwindow and enter theqBittorrent-4.6.7source code directory. Re-execute the configuration, compilation, and installation operations. No errors exist.
Compilation Result Testing
After the process ends, we find the binary executable file of this project in the $PREFIX directory /opt/apps/org.qbittorrent.qBittorrent/files/bin/qbittorrent and run the test in the container. * This operation needs to be performed in the terminal of the graphical desktop, otherwise the graphical interface of the program may not be invoked
It seems that because it is not directly started through the container, there is a problem that the runtime library cannot be found. Since the reported library is also in $PREFIX, we directly use the variable LD_LIBRARY_PATH to specify the dynamic runtime library search path
So far, it is sufficient to prove that Qt5-based open source application--qBittorrent can be successfully compiled and run in the Linyaps application container!


