Engine-folder preload helper for Linux: b2LoadNativeLibHere() (no sudo)#47
Merged
Merged
Conversation
Builds on the merged loader-assist (b2LoadNativeLib): the extension now locates
the running engine's own folder (realpath /proc/self/exe), strips to its
directory, and preloads <dir>/box2dxt.so by absolute path before any c:box2dxt>
binding resolves -- run from the first-call gateways (b2Version, checkABI). The
engine's later bare-name load then finds the already-resident copy, so a user
just drops box2dxt.so beside the OXT engine (or bundles it in a standalone) --
no /usr/lib, no sudo, no LD_LIBRARY_PATH, no script calls.
Off Linux realpath('/proc/self/exe') returns nothing and _ensureLib no-ops, so
Windows/macOS keep loading the library from beside the stack/app as before.
Requires the library soname to be box2dxt.so (build -DBOX2DXT_BARE_SONAME=ON).
No new C ABI symbol; b2Version() stays 4. Verified locally: bare-soname build
still emits box2dxt.so with soname box2dxt.so; .livecodescript gates pass. The
.lcb cannot be compiled headless -- needs an OXT load to confirm the
realpath/dlopen bindings resolve and the engine reuses the preloaded copy.
https://claude.ai/code/session_01EVV5fGeXqtWs8WDrmgWNku
The previous commit auto-called _ensureLib from b2Version/checkABI, which run on every platform -- but _ensureLib calls realpath (POSIX), so on Windows that binding would fail to resolve and make b2Version()/b2NewWorld() throw. Back out the auto-fire and expose the engine-folder preload as an explicit, Linux-only public handler b2LoadNativeLibHere(): it locates the engine via realpath /proc/self/exe and preloads <dir>/box2dxt.so. Callers gate it on the platform is Linux (the Kit will, once the preload is confirmed on Linux); b2Version/checkABI are back to their original cross-platform-safe form. No new C ABI symbol; b2Version() stays 4. .livecodescript gates pass; the .lcb still needs an OXT load to confirm the bindings compile and resolve. https://claude.ai/code/session_01EVV5fGeXqtWs8WDrmgWNku
SethMorrowSoftware
pushed a commit
that referenced
this pull request
Jun 15, 2026
b2kSetup now calls b2LoadNativeLibHere() when (and only when) the platform is Linux, so Kit/demo users get the no-sudo engine-folder load automatically while Windows/macOS never touch the POSIX path. The breakage that forced the helper to be a manual call in #47 was Windows-only -- realpath is absent there, but present and harmless on macOS -- so a single platform gate is enough. Drop box2dxt.so beside the engine (or bundle it in a standalone) and the demos run on Linux with no /usr/lib, no sudo, no LD_LIBRARY_PATH. - src/box2dxt-kit.livecodescript: gated preload at the top of b2kSetup. - examples/*: re-synced embedded Kit. - examples/box2dxt-selftest: bump kStHarnessV 18->19 + add stTestLoaderHelper (Linux-gated; on Linux it also proves the realpath/dlopen bindings resolve). https://claude.ai/code/session_01EVV5fGeXqtWs8WDrmgWNku
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.
Goal
Let Box2Dxt load on Linux with no
/usr/lib, nosudo, noLD_LIBRARY_PATH— dropbox2dxt.soin the OXT engine's own folder (or bundle it in a standalone) and a one-call helper preloads it. Builds on the merged loader-assist (b2LoadNativeLib, #46).What it adds
b2LoadNativeLibHere()(insrc/box2dxt.lcb): reads the running engine's own path viarealpath("/proc/self/exe"), strips to its folder, and preloads<folder>/box2dxt.soby absolute path. The engine's later bare-namedlopenthen finds the already-resident copy. For a standalone,/proc/self/exeis the standalone binary, so this covers shipping self-contained too.Important: it is an explicit, Linux-only helper — NOT auto-fired
realpath/dlopenare POSIX. An earlier revision of this PR auto-called the preload fromb2Version/checkABI, which run on every platform — that would make those bindings fail to resolve on Windows and throw. Backed out.b2Version/checkABIare now back to their original cross-platform-safe form, and the preload is an explicit call you make only whenthe platform is "Linux"(the Kit will gate it that way once the mechanism is confirmed). On Windows/macOS nothing here is touched — they already load the library from beside the stack/app.Requirements / caveats
box2dxt.so(build-DBOX2DXT_BARE_SONAME=ON, the flag from Linux loader-assist: install the .so without sudo (spike) #46) or a preloaded copy won't match the bare-name request.b2Version()stays4.Verified locally
box2dxt.sowith sonamebox2dxt.so.tools/check-livecodescript.pypasses; no_ensureLib/auto-call references remain.Needs an OXT pass (the gate)
The
.lcbcan't be compiled headless. Two separate things to confirm in OXT:.lcb,put b2Version()→ expect4, and run a demo — confirms the new bindings compile/load and nothing fires on Windows.box2dxt.so(bare-soname) on no search path,put b2LoadNativeLibHere()→1, thenput b2Version()→4. If green, the no-sudo engine-folder install works and the Kit gating + finalization follow.https://claude.ai/code/session_01EVV5fGeXqtWs8WDrmgWNku