Skip to content

[tools/rexm] Respect RAYLIB_LIBTYPE=STATIC during desktop linking#5545

Closed
TheLazyIndianTechie wants to merge 1 commit into
raysan5:masterfrom
TheLazyIndianTechie:codex/fix-rexm-static-linking
Closed

[tools/rexm] Respect RAYLIB_LIBTYPE=STATIC during desktop linking#5545
TheLazyIndianTechie wants to merge 1 commit into
raysan5:masterfrom
TheLazyIndianTechie:codex/fix-rexm-static-linking

Conversation

@TheLazyIndianTechie
Copy link
Copy Markdown
Contributor

Summary

Fix tools/rexm/Makefile so desktop builds actually honor RAYLIB_LIBTYPE=STATIC when selecting the raylib library to link.

Before this change, RAYLIB_LIBTYPE defaulted to STATIC but LDLIBS still used -lraylib, which can resolve to a shared library when one is present in src.

Problem Reproduction

Environment: macOS (clang), working from repository root.

  1. Build raylib shared library:
    cd src
    make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=SHARED CUSTOM_CFLAGS="-DGL_SILENCE_DEPRECATION" -B
  2. Build and run rexm with defaults:
    cd ../tools/rexm
    make clean && make
    ./rexm validate ../../examples/examples.h
  3. Runtime failure:
    dyld: Library not loaded: @rpath/libraylib.550.dylib
    Referenced from: .../tools/rexm/rexm
    Reason: no LC_RPATH's found
    

Root Cause

tools/rexm/Makefile sets RAYLIB_LIBTYPE ?= STATIC, but for desktop targets it still links with -lraylib, allowing the linker to pick a shared artifact when available.

Fix

  • Added RAYLIB_LINK_LIB:
    • $(RAYLIB_LIB_PATH)/libraylib.a when RAYLIB_LIBTYPE=STATIC
    • -lraylib otherwise
  • Replaced desktop LDLIBS raylib entry to use $(RAYLIB_LINK_LIB) on Windows/Linux/macOS/BSD.

Validation

  • make clean && make in tools/rexm now links explicitly to ../../src/libraylib.a by default.
  • otool -L ./rexm no longer shows a dynamic libraylib dependency in static mode.
  • ./rexm --help and ./rexm validate ../../examples/examples.h run successfully in static mode, even with shared raylib artifacts present in src.

Scope

Small Makefile-only change in tools/rexm/Makefile; no behavior changes outside library selection for linking.

@raysan5
Copy link
Copy Markdown
Owner

raysan5 commented Feb 10, 2026

Both lines are exactly the same, not sure how it has been tested.

@raysan5 raysan5 closed this Feb 10, 2026
@TheLazyIndianTechie TheLazyIndianTechie deleted the codex/fix-rexm-static-linking branch February 10, 2026 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants