Fix macOS link: use ld64 flags instead of GNU ld ones

ld64.lld rejects --allow-shlib-undefined and -rpath=$ORIGIN. Add a
macOS branch with -undefined dynamic_lookup and an @executable_path
rpath, and skip the Linux-only patchelf step in the justfile.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Greg Shuflin
2026-09-08 15:26:20 -07:00
co-authored by Claude Fable 5.1
parent a54101b48e
commit 2de47f0db9
2 changed files with 10 additions and 2 deletions
+5
View File
@@ -28,10 +28,15 @@ run-webcam-demo: build-webcam-demo
_build binary-name:
lake build {{binary-name}} --verbose
[linux]
_perform_nix_patch binary-name:
patchelf --set-interpreter /usr/lib/ld-linux-x86-64.so.2 .lake/build/bin/{{binary-name}}
patchelf --set-rpath '$ORIGIN:/usr/lib' .lake/build/bin/{{binary-name}}
[macos]
_perform_nix_patch binary-name:
@true
# Build the C version of the SDL3 webcam
[group: "C_build"]
+5 -2
View File
@@ -144,9 +144,12 @@ def sdlLinkLibs : TargetArray Dynlib := #[libSDL3, libSDL3Image, libSDL3Ttf, lib
-- make sure to copy these link args into whatever project is using this library in order for it to work
-- This is because without "-rpath=$ORIGIN", the Linux executable will not load dynlibs next to the executable (i.e., the SDL ones you've copied there).
def sdlLinkArgs : Array String := if Platform.isWindows
then
-- macOS's ld64 spells both flags differently: `-undefined dynamic_lookup` and `@executable_path` in place of `$ORIGIN`.
def sdlLinkArgs : Array String :=
if Platform.isWindows then
#[]
else if Platform.isOSX then
#["-Wl,-undefined,dynamic_lookup", "-Wl,-rpath,@executable_path"]
else
#["-Wl,--allow-shlib-undefined", "-Wl,-rpath=$ORIGIN"]