libcommon is a collection of reusable C++ code shared by many C++ projects at CM4all GmbH.
The project was created when code duplication between C++ projects got out of hand. Commonly used code was moved into this library, instead of keeping several copies in sync.
The library is meant to be included in other projects as a git submodule. It is a lively and volatile project, which makes it hard to turn it into a shared library. Retaining ABI stability (which is very difficult with C++ anyway) would be too hard at this stage, and not worthwile.
You need:
- a C++23 compiler (GCC or clang)
- Meson 1.2
- libfmt
- libsystemd
- libdbus
- libcap
- libseccomp
- OpenSSL
Optional dependencies:
- Avahi
- libcurl
- libmariadb
- libpq
- libsodium
- liburing
- libwas
- LuaJit
- Nettle
- nlohmann_json
- PCRE
- GoogleTest
To build it, type:
meson . build ninja -C build
That produces several static libraries.
Each directory below src contains a sub-library:
- adata: data structures using our pool allocator
- co: C++20 Coroutines
- event: a non-blocking I/O event loop
- event/co: integration of C++20 Coroutines into our event loop
- event/net: non-blocking networking libraries
- event/systemd: non-blocking systemd clients
- event/uring: integration of io_uring in the event loop
- http: HTTP protocol definitions and helpers
- io: file I/O utilities
- io/config: a configuration file parser
- io/linux: Linux-specific I/O helpers
- io/uring: liburing C++ wrapper
- jwt: helpers for JSON Web Tokens
- lib: C++ wrappers or additional utilities for various external libraries.
- lua: Lua C++ wrappers
- lua/event: non-blocking Lua
- lua/io: I/O helpers for Lua
- lua/json: Lua JSON library
- lua/mariadb: Lua wrapper for libmariadb
- lua/net: networking helpers for Lua
- lua/pg: non-blocking PostgreSQL client for Lua
- lua/sodium: Lua wrappers for libsodium
- memory: memory allocators
- net: networking/socket utilities
- net/control: the control protocol (a datagram-based protocol to control several of our daemons)
- net/djb: implementations of protocols designed by D. J. Bernstein
- net/linux: Linux-specific networking utilities
- net/log: our multicast-based logging protocol
- pg: libpq C++ wrappers
- spawn: a process spawner
- stock: manage stocks of reusable objects (e.g. for connection pooling)
- system: operating system utilities
- system/linux: Linux-specific utilities, e.g. system call wrappers
- thread: helpers for multi-threaded applications
- time: dealing with date and time
- translation: implementation of the CM4all translation protocol
- translation/server: non-blocking translation server framework
- uri: URI utilities
- util: generic utilities
- was: helpers for libwas
- was/async: a non-blocking implementation of the Web Application Socket protocol
These directories contain C++ wrappers or additional utilities for external libraries:
- lib/avahi: Avahi C++ wrappers
- lib/cap: libcap C++ wrappers
- lib/curl: libcurl C++ wrappers
- lib/dbus: libdbus C++ wrappers
- lib/fmt: libfmt helpers
- lib/mariadb: C++ wrappers for the MariaDB client library
- lib/nettle: Nettle C++ wrappers
- lib/nlohmann_json: nlohmann_json helpers
- lib/openssl: OpenSSL C++ wrappers
- lib/pcre: PCRE C++ wrappers
- lib/sodium: libsodium C++ wrappers
- lib/zlib: zlib C++ wrappers
Special directories:
- pluggable: contains fallback implementations for modules that should be replaced by applications using libcommon