From 353c1c0ff1b7acbfcdef675355d0bc83eab8ec28 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Thu, 1 Oct 2026 20:23:34 -0400 Subject: [PATCH 1/2] Fix duplicate raymath symbols in modules --- examples/module/main.cpp | 11 ++++++++++- include/raymath.hpp | 5 +++-- modules/raylib.cppm | 1 - 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/examples/module/main.cpp b/examples/module/main.cpp index dfeaa59f..d673b025 100644 --- a/examples/module/main.cpp +++ b/examples/module/main.cpp @@ -10,18 +10,27 @@ import raylib; using raylib::Color; +using raylib::Vector2; using raylib::Window; int main() { int screenWidth = 800; int screenHeight = 450; + // Mixing raymath with raylib runtime calls must not produce duplicate symbols when linking against raylib. + Vector2 textPosition = Vector2(100, 180) + Vector2(20, 20); + Window window(screenWidth, screenHeight, "raylib-cpp - modules example"); while (!window.ShouldClose()) { window.BeginDrawing(); window.ClearBackground(raylib::Colors::RAYWHITE); - raylib::DrawText("Congrats! You imported raylib as a module!", 120, 200, 20, Color::LightGray()); + raylib::DrawText( + "Congrats! You imported raylib as a module!", + static_cast(textPosition.x), + static_cast(textPosition.y), + 20, + Color::LightGray()); window.EndDrawing(); } diff --git a/include/raymath.hpp b/include/raymath.hpp index 8d012ff0..6d299d04 100644 --- a/include/raymath.hpp +++ b/include/raymath.hpp @@ -8,11 +8,12 @@ extern "C" { #endif #ifndef RAYLIB_CPP_NO_MATH -#ifndef BUILD_RAYLIB_CPP_MODULES +// raylib already provides out-of-line definitions for every raymath function, so raylib-cpp must never emit its +// own. Anything other than RAYMATH_STATIC_INLINE gives these functions external linkage and makes them clash with +// libraylib when a translation unit pulls in both. #ifndef RAYMATH_STATIC_INLINE #define RAYMATH_STATIC_INLINE #endif -#endif #ifdef __GNUC__ #pragma GCC diagnostic push // These throw a warnings on visual studio, need to check if __GNUC__ is defined to use it. #pragma GCC diagnostic ignored "-Wmissing-field-initializers" diff --git a/modules/raylib.cppm b/modules/raylib.cppm index d9bca093..ba3cabac 100644 --- a/modules/raylib.cppm +++ b/modules/raylib.cppm @@ -9,7 +9,6 @@ module; #define BUILD_RAYLIB_CPP_MODULES #define RLCPPAPI -#define RAYMATH_IMPLEMENTATION #include "../include/raylib-cpp.hpp" #undef LIGHTGRAY From afc41e263d969826e64f544349814a524fc5ca08 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Fri, 2 Oct 2026 00:56:31 -0400 Subject: [PATCH 2/2] Remove unneeded comments --- include/raymath.hpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/raymath.hpp b/include/raymath.hpp index 6d299d04..c981b3ca 100644 --- a/include/raymath.hpp +++ b/include/raymath.hpp @@ -8,9 +8,6 @@ extern "C" { #endif #ifndef RAYLIB_CPP_NO_MATH -// raylib already provides out-of-line definitions for every raymath function, so raylib-cpp must never emit its -// own. Anything other than RAYMATH_STATIC_INLINE gives these functions external linkage and makes them clash with -// libraylib when a translation unit pulls in both. #ifndef RAYMATH_STATIC_INLINE #define RAYMATH_STATIC_INLINE #endif