Building static GLFW[wayland]

I’ve (mostly) managed to build GLFW wayland static variant from source using meson with wayland-scanner. The only thing I’m missing is the following macros inside src/wl_platform.h:

#define wl_display_flush _glfw.wl.client.display_flush
#define wl_display_cancel_read _glfw.wl.client.display_cancel_read
#define wl_display_dispatch_pending _glfw.wl.client.display_dispatch_pending

So what i understand is that the wayland-client functions are imported from <wayland-client-core.h>. But then they are overriden by these defines and i don’t really understand what they are for (maybe for dynamic linking or smth? I read in the wiki that static linking is default in CMake but i couldn’t find much about this behavior ). Here’s the i used

If i remove such defines the library compiles and works as expected. I’d like to get this to work with unmodified codebase so i can directly use GLFW as a submodule. Any help or knowledge would be much appreciated.

Best regards, krr.

Hi @cykrr

Welcome to the GLFW forum.

These define macros simply replace occurrences of the first word with the rest of the sentence. so wl_display_flush is replaced with _glfw.wl.client.display_flush when compiled by the C preprocessor.

You can’t remove these, since the macros are used through the wayland GLFW source code. For example wl_display_flush appears in wl_window.c and wl_init.c.

The function _glfwInitWayland in wl_init.c initializes all the _glfw.wl.client.* function pointers, after the Wayland library is loaded by _glfwConnectWayland.

I’m a little confused as to how you could be ‘missing’ these, as they are in a header file which should is included by the Wayland source files for GLFW, and I don’t know anything about the Meson build system. It might be useful to paste (as text) the error message you are getting.