Auto-load the native library on Linux via the Kit (platform-gated, no Windows/Mac impact)#48
Merged
Merged
Conversation
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
SethMorrowSoftware
pushed a commit
that referenced
this pull request
Jun 15, 2026
Moves the auto-load into the extension itself so it works for BOTH Kit and raw b2* callers, with nothing baked into individual stacks -- the cleaner home the Kit gating was a stand-in for. _autoEnsure() calls b2LoadNativeLibHere() inside a try/catch and is invoked from b2Version/checkABI (the gateways). On Linux it preloads from the engine folder; on macOS it returns 0 (no /proc); on Windows the POSIX realpath binding throws and the catch swallows it, so nothing breaks. This is a SPIKE: its whole purpose is to confirm LiveCode Builder supports try/catch. If the extension compiles in OXT, it does -- and we can drop the Kit gating (#48) in a follow-up. If it will NOT compile, try/catch is unavailable and we keep the Kit approach (the merged main) or switch to a getenv platform check. The Kit gating is intentionally left in place here so Linux still loads during the spike; the redundancy is harmless. https://claude.ai/code/session_01EVV5fGeXqtWs8WDrmgWNku
This was referenced Jun 15, 2026
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
Make the no-sudo Linux load automatic — drop
box2dxt.sobeside the OXT engine (or bundle it in a standalone) and Kit/demo stacks load it on their own, with no Windows/Mac regression.The key insight
The auto-fire that broke Windows in #47 was Windows-only:
realpathdoesn't exist there, so the binding threw. Butrealpathdoes exist on macOS (it's POSIX) and harmlessly returns nothing (no/proc). So we don't need to avoid the call everywhere — just on Windows. A single platform gate is enough.The change
b2kSetup(the Kit's world-creation entry, which runs before any physics call) now does:box2dxt.sofrom the engine's own folder before the first binding resolves → it just works, no sudo.the platformis rock-solid in LiveCodeScript, so the gate is reliable (unlike platform detection inside the LCB, which is why this lives in the Kit, not inb2Version/checkABI).Scope
src/box2dxt-kit.livecodescript— the one gated line at the top ofb2kSetup.examples/*— re-synced embedded Kit (tools/sync-embedded-kit.py).examples/box2dxt-selftest.livecodescript—kStHarnessV18→19 and a newstTestLoaderHelper: on Linux it assertsb2LoadNativeLibHere()returns a 0/1 flag without error (which also proves therealpath/dlopenbindings resolve); off Linux it records that the gate skips it.Verified locally
tools/check-livecodescript.pypasses — Kit + all examples balanced, no smart quotes, embedded Kit in sync.Needs an OXT pass
Still the same gate as before: on a Linux box, build the lib with
-DBOX2DXT_BARE_SONAME=ON, drop it beside the engine, open a demo (or run the self-test) — it should load with no sudo. On Windows, loading a demo should behave exactly as today (the gate skips the new path).Note
Covers Kit/demo usage (which is all the examples and the typical user). Raw
b2*-only users on Linux still callb2LoadNativeLibHere()themselves — documented on the handler.https://claude.ai/code/session_01EVV5fGeXqtWs8WDrmgWNku
Generated by Claude Code