Monthly update, August 2024

Published Updated

By Jarle Aase

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.

find_package(Boost REQUIRED MODULE COMPONENTS     system     context     chrono     json     program_options     )

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.

# Use a base image with a compatible Linux distributionFROM ubuntu:24.04# Set environment variablesENV QT_VERSION=6.8ENV QT_DIR=/opt/qt-buildENV VCPKG_ROOT=/opt/vcpkgENV DEBIAN_FRONTEND=noninteractive# Install necessary toolsRUN apt-get update && apt-get install -y \    build-essential \    clang libclang-dev \    libgl1-mesa-dev libglew-dev libglu1-mesa-dev libegl1-mesa-dev \    libx11-dev libxext-dev libxrandr-dev libxrender-dev libwayland-dev \    cmake googletest \    ninja-build \    git \    perl \    python3 \    python3-pip \    curl \    wget \    pkg-config \    zlib1g-dev \    libgstreamer1.0-dev \    libgstreamer-plugins-base1.0-dev \    gstreamer1.0-plugins-good \    gstreamer1.0-plugins-bad \    gstreamer1.0-plugins-ugly \    gstreamer1.0-libav \    libpulse-dev \    libasound2-dev \    libva-dev \    libvdpau-dev \    libavcodec-dev \    libavformat-dev \    libswscale-dev \    libavutil-dev \    libjpeg-dev \    libpng-dev \    libv4l-dev \    libjpeg-turbo8-dev \    libpng-dev \    openssl \    libsqlite3-dev \    libcurl4-openssl-dev \    libpulse-dev \    zip unzip tar wget \    pkg-config \    autoconf \    libfreetype-dev \    libharfbuzz-dev \    libhunspell-dev \    libcups2-dev libcupsfilters-dev \    flite1-dev \    && rm -rf /var/lib/apt/lists/*# Install vcpkgRUN git clone https://github.com/microsoft/vcpkg.git ${VCPKG_ROOT} && \    ${VCPKG_ROOT}/bootstrap-vcpkg.sh# Install necessary Qt dependencies using vcpkgWORKDIR ${VCPKG_ROOT}RUN ./vcpkg install protobuf grpc openssl \    boost-system boost-context boost-coroutine boost-filesystem \    boost-asio boost-chrono boost-date-time boost-log boost-regex boost-json \    boost-url boost-uuid boost-mysql boost-charconv boost-program-options boost-functional# Create directory for Qt installationRUN mkdir -p ${QT_DIR}# Clone Qt source codeRUN git clone --branch ${QT_VERSION} git://code.qt.io/qt/qt5.git ${QT_DIR}/qt# Initialize the repository and synchronize submodulesWORKDIR ${QT_DIR}/qtRUN ./init-repository --module-subset=default,-qtwebengineRUN ./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# Build and install QtRUN cmake --build . --parallelRUN cmake --install .RUN egrep -i 'grpc|proto' config.summary# Default commandCMD ["/bin/bash"]