ocornut/imgui

GLFW backend compile fails because wayland-client.h cannot be found

Closed this issue ยท 4 comments

Discussed in #9020

Originally posted by jagot October 19, 2025
Apologies if this should be an issue instead.

Slightly related to: #8969

If I try to compile ImGui with the GLFW backend on a Linux machine that does not have Wayland or any of its headers installed, the compile fails since ImGui insists on defining GLFW_EXPOSE_NATIVE_WAYLAND before including GLFW/glfw3native.h.

If I comment out

#ifndef GLFW_EXPOSE_NATIVE_WAYLAND
#define GLFW_EXPOSE_NATIVE_WAYLAND
#endif
GLFW picks up the X11 headers instead and the compile is successful.

Thank you @jagot. This is a new issue caused by 10d0162 (#8921, #8920) and should be fixed.

We overlooked this case.
@pthom, @TheBrokenRail any feedback?

How could be consider detecting that case?

Perhaps we can use __has_include to detect wayland-client.h ?
https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005finclude.html
#include <wayland-client.h>

From a quick look, GLFW_EXPOSE_NATIVE_WAYLAND isn't ever actually used. ImGui_ImplGlfw_IsWayland never calls any of the glfwGetWayland* functions. On new versions of GLFW, it uses glfwGetPlatform. And on old versions, it checks glfwGetVersionString and glfwGetX11Display.

Right, it doesn't seem used in Docked branch either. I'm out now but will remove it soon.

Pushed a fix now. Thank you!