Published:

Jarle Aase

Monthly update, August 2024

bookmark 4 min read

These monthly updates may be a bit technical. They are written to my future self (to remember how I spent the month - and to motivate me to do at least something remotely interesting), to friends and colleagues (past and future) to have an idea about what I work on. And of course to potential clients for my C++ freelance business and fellow software developers.

Projects

Mysqlpool

Mysqlpool is lightweight async connection-pool library, built on top of boost.mysql.

This library is actually pretty awesome. I use it in the NextApp server, and most of the time I forget that it exists. It just does it's magic without causing any friction.

I ran into some problems when I used it with a root project that fetched boost via Conan. I fixed that by using MODULE in find_package.

1find_package(Boost REQUIRED MODULE COMPONENTS
2     system
3     context
4     chrono
5     json
6     program_options
7     )

I should probably have done that in the first place.

I also fixed a build failure with boost 1.86, where asio had changed it's api (again). These API changes in asio (and other libraries) are annoying for library maintainers that aim to support older Debian/Ubuntu LTS versions.

restc-cpp

restc-cpp The magic that takes the pain out of accessing JSON API's from C++.

This is a library that has achieved some popularity. If something breaks, fixing it is a high priority. I discovered that the build was broken with g++14. So I fixed it. In order to to that, I had to finish migrating my Jenkins VM from a server in the basement to a new VM on my workstation, along with new worker VM's for docker and a new worker VM with Windows. I also re-added MacOS to the list of operating systems I test on, in addition to adding SUSE Linux and Ubuntu Noble.

While I was at it, I ran the code trough static code analyzers and fixed any sane complaints they came up with. It's been a while since last time I did this. Finally I got rid of most of the warnings while compiling under Windows.

I added a matrix build on Github Actions that builds the library and run the unit tests under Ubuntu (g++ and clang), Windows (msvc) and MacOS (clang). Now I have that cool, green "CI Passing" button on the projects GitHub page :)

There are things I wish I had time to implement, but it has to wait for now. The library is in good shape.

Next-App

Next-app is an upcoming GTD/productivity application for desktop and mobile.

I have switched to this app now. Lots of the work in August was small improvements to make it better in everyday use. One tiny feature that actually made a big difference was sounds when calendar events are coming up, starts, are about to finish and have finished. This makes the time-block feature work as intended for me. Up until now, I frequently forgot that I was supposed to do something else, or anything at all :)

I also tweaked the various dialogs to work on both Desktop and Android.

I got the app to compile and work under Windows and MacOS! It's not polished or properly tested yet, but the app starts and simple interaction works. This was something that I dreaded a bit. I use Linux Desktop myself. Most users of this application will probably use Windows and/or MacOS. After lots of cold showers getting the Android version working, I really feared that something fundamental would break when I tried to get it to work on the most popular platforms.

The gRPC library from QT that I use in the client is in "Technical Preview". That means that the API changes between 6.8 beta releases. So I usually loose a day or two to adapt to the latest changes when I update to the latest version.

I wanted this nice green "CI Passing" button on this project as well, so I added the backend to Github Actions. Initially that did not work at all. I used vcpkg to get the dependencies, including protobuf and gRPC. The libraries in Debian and Ubuntu is quite old. Google has done significant changes in these projects, including their dependencies. That may be why the maintainers of the Debian package is holing back. When I got the latest version with vcpkg, nothing compiled. I had to do some refactoring of my cmake files to fix this, and it took days. This is one of the downsides with C++. When dependencies break, you can easily waste a week on the tooling just to compile your project. I have not added the client yet, as I am unsure how to compile a QT project on GitHub Actions in a timely manner. Compiling QT from sources take quite some time, even on my workstation with 64 vcpu's.

Compiling QT statically from sources

Speaking about compiling QT from sources. I tried to do that, so I can make a Linux binary without shipping gigabytes of shared QT libraries. However, I was unable to get QT Protobuf to work. Parts of the grpc libraries was available, but a few parts were missing, making it impossible to use it to build the NextApp client. After days of throwing spaghetti at the wall, I finally discovered that the QT sources require a newer Protobuf library than the one shipped with Ubuntu Noble. Using the Dockerfile below, I got a static build of QT with Protobuf, gRPC and hopefully everything else I need (I have not tried to build the NextApp client using it yet. When I finally was able to build QT, there were too many tasks on my lists that had passed their due-time).

Building this Dockerfile on my workstation takes ~34 minutes. It would probably take many hours on Github Actions runners. The image is 21GB, so it's not practical to push it to docker hub.

 1# Use a base image with a compatible Linux distribution
 2FROM ubuntu:24.04
 3
 4# Set environment variables
 5ENV QT_VERSION=6.8
 6ENV QT_DIR=/opt/qt-build
 7ENV VCPKG_ROOT=/opt/vcpkg
 8ENV DEBIAN_FRONTEND=noninteractive
 9
10# Install necessary tools
11RUN apt-get update && apt-get install -y \
12    build-essential \
13    clang libclang-dev \
14    libgl1-mesa-dev libglew-dev libglu1-mesa-dev libegl1-mesa-dev \
15    libx11-dev libxext-dev libxrandr-dev libxrender-dev libwayland-dev \
16    cmake googletest \
17    ninja-build \
18    git \
19    perl \
20    python3 \
21    python3-pip \
22    curl \
23    wget \
24    pkg-config \
25    zlib1g-dev \
26    libgstreamer1.0-dev \
27    libgstreamer-plugins-base1.0-dev \
28    gstreamer1.0-plugins-good \
29    gstreamer1.0-plugins-bad \
30    gstreamer1.0-plugins-ugly \
31    gstreamer1.0-libav \
32    libpulse-dev \
33    libasound2-dev \
34    libva-dev \
35    libvdpau-dev \
36    libavcodec-dev \
37    libavformat-dev \
38    libswscale-dev \
39    libavutil-dev \
40    libjpeg-dev \
41    libpng-dev \
42    libv4l-dev \
43    libjpeg-turbo8-dev \
44    libpng-dev \
45    openssl \
46    libsqlite3-dev \
47    libcurl4-openssl-dev \
48    libpulse-dev \
49    zip unzip tar wget \
50    pkg-config \
51    autoconf \
52    libfreetype-dev \
53    libharfbuzz-dev \
54    libhunspell-dev \
55    libcups2-dev libcupsfilters-dev \
56    flite1-dev \
57    && rm -rf /var/lib/apt/lists/*
58
59
60# Install vcpkg
61RUN git clone https://github.com/microsoft/vcpkg.git ${VCPKG_ROOT} && \
62    ${VCPKG_ROOT}/bootstrap-vcpkg.sh
63
64# Install necessary Qt dependencies using vcpkg
65WORKDIR ${VCPKG_ROOT}
66RUN ./vcpkg install protobuf grpc openssl \
67    boost-system boost-context boost-coroutine boost-filesystem \
68    boost-asio boost-chrono boost-date-time boost-log boost-regex boost-json \
69    boost-url boost-uuid boost-mysql boost-charconv boost-program-options boost-functional
70
71# Create directory for Qt installation
72RUN mkdir -p ${QT_DIR}
73
74# Clone Qt source code
75RUN git clone --branch ${QT_VERSION} git://code.qt.io/qt/qt5.git ${QT_DIR}/qt
76
77# Initialize the repository and synchronize submodules
78WORKDIR ${QT_DIR}/qt
79
80RUN ./init-repository --module-subset=default,-qtwebengine
81
82RUN ./configure -prefix /opt/qt-static -static -release -opensource -confirm-license -no-pch -nomake examples -nomake tests -openssl-linked -opengl desktop -sql-sqlite -skip qtwebengine -vcpkg --feature-protobufquick --feature-qtprotobufgen
83
84# Build and install Qt
85RUN cmake --build . --parallel
86RUN cmake --install .
87
88RUN egrep -i 'grpc|proto' config.summary
89
90# Default command
91CMD ["/bin/bash"]
92