Akadata Linux · Version 0 Saphira

fmt — C++ formatting library

Use the fmt 12.1 C++ formatting library on Akadata Linux: include, link, format chrono types, ranges, and package your application into stage4.

Saphira, the Akadata Linux Version 0 mascot
Technical preview

Stack guide — fmt

fmt 12.1 — C++ formatting library

fmt is the modern C++ formatting library: fast, safe, and a direct replacement for printf and iostreams. It is installed as a system library on Akadata Linux and is available to any C++ project that links against it.

The library provides fmt::print, fmt::format, and compile‑time format‑string checking. It integrates with C++20 std::format where the compiler supports it.


Usage

Include and link

The headers are in the standard system include path. Link with -lfmt:

#include <fmt/core.h>

int main() {
    fmt::print("Hello, {}!\n", "Akadata Linux");

    std::string s = fmt::format("The answer is {}.\n", 42);
    fmt::print("{}", s);

    return 0;
}

Compile with GCC 16.1, matching the distribution baseline:

g++ -O3 -march=x86-64-v3 -std=c++20 -o /usr/local/bin/myapp myapp.cpp -lfmt

The -std=c++20 flag enables std::format support, but {fmt} works with C++14 and later. The system fmt is compiled with x86-64-v3 and O3, matching the rest of the distribution.


Features

Beyond printf

fmt supports positional arguments, named arguments, chrono formatting, range and tuple formatting, and user‑defined type formatters:

// Positional arguments
fmt::print("{1} comes before {0}\n", "second", "first");

// Chrono formatting
#include <fmt/chrono.h>
auto now = std::chrono::system_clock::now();
fmt::print("Date: {:%Y-%m-%d %H:%M:%S}\n", now);

// Format a vector
#include <fmt/ranges.h>
std::vector<int> v = {1, 2, 3, 4};
fmt::print("Vector: {}\n", v);  // Prints [1, 2, 3, 4]

For full documentation, see fmt.dev. The man page is available at man fmt.


Production

Package your fmt‑based application

If your application uses fmt, declare it as a dependency in your stage4 recipe. The package manager will ensure the library is present at build time and runtime:

# packages/myapp/recipe.sh
depends="fmt"
source="https://example.com/myapp-1.0.tar.gz"

When your recipe runs, the fmt headers and library are already on the system. Your binary links against the same fmt that ships with the distribution. No vendored copies, no submodules, no ABI surprises.