Repository navigation
0.1.2: shared libraries at run time (mcpplibs.os.library) - #5
Merged
Merged
Conversation
A plugin system loads a module by name, and an extension that another program loads needs that program's functions, which it did not link against (a Python extension and the interpreter's C API). Both need the dynamic loader, which openkal does not cover: it belongs to the C library on Linux and macOS and to kernel32 on Windows. The new module mcpplibs.os.library: - open(path or name) answers a handle that closes the library when it goes; the library's symbols stay local to it; - loaded(name) finds a library the process already has, without loading it; - handle::symbol and function<F> look up what a library defines; - process_symbol(name) resolves a symbol as the loader does: the global scope on POSIX, every module of the process on Windows; - suffix() is the system's library suffix. The implementations are src/posix/library.cpp (dlopen), src/windows/library.cpp (kernel32, declared in win32.h) and src/openkal/library.cpp (an image loads nothing). library_test opens a system library by name, calls one of its functions, finds a loaded library and a program symbol, and gets an error for a missing library.
…image) loads no library and open() says so
Sunrisepeak
added a commit
to mcpplibs/mcpp-index
that referenced
this pull request
Oct 27, 2026
…#584) mcpplibs/os#5 adds the dynamic loader: open a library by path or name, find one the process already has, look up its symbols, and resolve a symbol of the program as the loader does. openmui's Python binding reaches the interpreter's stable C API this way, without headers or an import library. The consumer test moves to 0.1.2 and resolves a program symbol.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
mcpplibs.os.library, the dynamic loader. Two cases need it:openkal does not cover the loader: it is the C library's on Linux and macOS and kernel32's on Windows. So the implementations are per system, beside
machine. The README says so.API:
open(path or name)returns a handle that closes the library when it goes. The library's symbols stay local to it (RTLD_LOCAL).loaded(name)finds a library already in the process, without loading it.symbolandfunction<F>look up what the library defines.process_symbol(name)resolves a symbol as the loader does: the global scope on POSIX, every module of the process in load order on Windows.suffix()is the system's library suffix.Tests (
tests/library_test.cpp):Checked locally with LLVM on Linux. This CI is the first macOS, Windows (LLVM and MSVC) and GCC run. Version 0.1.2.