Systems programming experiment

Better Dynamic Libraries

A small C++23 abstraction for loading shared libraries and resolving typed functions through one interface on Windows and POSIX systems.

Overview

A focused wrapper around platform-specific loading APIs.

Dynamic-library access differs at the operating-system boundary. This project presents a shared DynamicLibrary interface while keeping the Windows and POSIX implementations behind the class. Loaded handles are released by the object destructor, tying resource lifetime to C++ scope.

Platform bridge

One lifecycle, two native implementations.

Public APILoad a path and request a function by name.

WindowsLoadLibraryA, GetProcAddress, and FreeLibrary.

POSIXdlopen, dlsym, and dlclose.

Public interface

Typed lookup with explicit errors.

Factory overloads accept character strings, standard strings, or filesystem paths. Function lookup returns either a callable with the requested signature or an explanatory error string.

header/dynamicLibraries.hppC++
[[nodiscard]] static DynamicLibrary load(
    const std::filesystem::path&
);

template<typename TFunction>
std::expected<std::function<TFunction>, std::string>
getFunction(const std::string&) const;
Current scope

A compact experiment, not a full plugin framework.

The repository concentrates on library ownership, symbol resolution, and cross-platform compilation. It does not attempt dependency discovery, version negotiation, hot reloading, or a higher-level plugin protocol. Those boundaries keep the code useful as a study of the native loading layer itself.