This is a workaround for dynamic libraries initializers not being properly sequenced (e.g. an ELF shared library).
| Release Version | Release Notes | AI Documentation |
|---|---|---|
| RELEASENOTES | DeepWiki for mulle-atinit |
You must statically link the mulle-atinit library with your executable. Ensure that global symbols are exported and that the whole library is linked to the executable and not optimized away by the linker.
| Platform | Linker Flags |
|---|---|
| Linux | -Wl,--export-dynamic -Wl,--whole-archive |
| macos | -force_load <library> |
Any participating shared library constructor uses
mulle_atinit( f, userinfo, priority);to defer f to a later date.
The function f will be called properly sequenced before main. userinfo will
be passed as the only parameter. You use priority 0 normally. Use higher
priorities to move initializers ahead.
If you are linking your executable statically and dlsym is not available
(musl) then you must define __MULLE_STATICALLY_LINKED__, when building all
dependencies that use mulle_atinit. Dynamic linking with a missing dlsym
won't work.
Use mulle-sde to add mulle-atinit to your project:
mulle-sde add github:mulle-core/mulle-atinitTo only add the sources of mulle-atinit with dependency sources use clib:
clib install --out src/mulle-core mulle-core/mulle-atinitAdd -isystem src/mulle-core to your CFLAGS and compile all the sources that were downloaded with your project.
Use mulle-sde to build and install mulle-atinit and all dependencies:
mulle-sde install --prefix /usr/local \
https://github.com/mulle-core/mulle-atinit/archive/latest.tar.gzPreferably install mulle-core and be done with it:
| Requirements | Description |
|---|---|
| mulle-core | 🌋 Almagamated library of mulle-core + mulle-concurrent + mulle-c |
Or if you really want to do it exhaustively:
| Requirements | Description |
|---|---|
| mulle-thread | 🔠 Cross-platform thread/mutex/tss/atomic operations in C |
| mulle-dlfcn | ♿️ Shared library helper |
Download the latest tar or zip archive and unpack it.
Install mulle-atinit into /usr/local with cmake:
PREFIX_DIR="/usr/local"
cmake -B build \
-DMULLE_SDK_PATH="${PREFIX_DIR}" \
-DCMAKE_INSTALL_PREFIX="${PREFIX_DIR}" \
-DCMAKE_PREFIX_PATH="${PREFIX_DIR}" \
-DCMAKE_BUILD_TYPE=Release &&
cmake --build build --config Release &&
cmake --install build --config ReleaseNat! for Mulle kybernetiK