Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] Cannot use GLFW runtime platform detection #3850

Closed
M374LX opened this issue Mar 1, 2024 · 4 comments · Fixed by #3863
Closed

[build] Cannot use GLFW runtime platform detection #3850

M374LX opened this issue Mar 1, 2024 · 4 comments · Fixed by #3863

Comments

@M374LX
Copy link
Contributor

M374LX commented Mar 1, 2024

The big new feature of GLFW 3.4 is runtime platform detection, which enables a single Linux executable to run on both X11 and Wayland. However, raylib cannot use this feature at the moment when built using the Makefile or Zig, although it works when raylib is built using CMake.

The reason is because the Makefile and Zig use the file rglfw.c, which is not used by CMake, and rglfw.c combines all of GLFW's source files needed for a single platform selected at build time into one file. However, it is not possible to include multiple platforms into a single source file because GLFW has some static functions with the same name in source files for different platforms. Moreover, GLFW expects the "null" platform to be always present but we cannot include it for the same reason.

Maybe we should get rid of rglfw.c and have the Makefile and Zig select the GLFW source files to be built.

This problem has been previously reported here: #3827 (comment).

@orcmid
Copy link
Contributor

orcmid commented Mar 1, 2024

I am concerned that elimination of rglfw.c may create difficulties for desktop builds that now include it without using Make or CMake. E.g., in raylib/projects/scripts and elsewhere, including simple builds of examples.

@M374LX
Copy link
Contributor Author

M374LX commented Mar 1, 2024

It looks like modifying the bundled GLFW by adding platform-specific suffixes to the functions with conflicting names is an easier solution than removing rglfw.c.

@raysan5
Copy link
Owner

raysan5 commented Mar 7, 2024

I prefer to keep rglfw.c, it amalgamates all GLFW into a single module and it simplifies a lot compilation process.

In any case, how does CMake/GLFW resolve this same issue? Because build process is also supposed to compile and link all those symbols with the same name.

@M374LX
Copy link
Contributor Author

M374LX commented Mar 8, 2024

When building with CMake, instead of using rglfw.c, GLFW's CMakeLists.txt is included along with raylib's own CMakeLists.txt, as seen in https://github.com/raysan5/raylib/blob/master/cmake/GlfwImport.cmake.

Anyway, keeping rglfw.c and just renaming GLFW's functions with conflicting names is indeed a simpler solution.

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 a pull request may close this issue.

3 participants