Building with Meson fails: requires OpenGLES

Hello!
I tried to build a sample project with Meson, following steps from the official tutorial but it failed showing errors about OpenGLES2 headers which I did not intend to use.

I copy-pasted all the code and the commands, only changing the project name to “t”.

meson.build:

project('t', 'c', default_options: 'default_library=static')

sdl2_dep = dependency('sdl2')

executable(
    't',
    'main.c',
    win_subsystem: 'windows',
    dependencies: [sdl2_dep]
)
main.c
#include "SDL2/SDL.h"

int main(int argc, char *argv[])
{
    SDL_Window *window;
    SDL_Renderer *renderer;
    SDL_Surface *surface;
    SDL_Event event;

    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError());
        return 3;
    }

    if (SDL_CreateWindowAndRenderer(320, 240, SDL_WINDOW_RESIZABLE, &window, &renderer)) {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window and renderer: %s", SDL_GetError());
        return 3;
    }

    while (1) {
        SDL_PollEvent(&event);
        if (event.type == SDL_QUIT) {
            break;
        }
        SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0x00);
        SDL_RenderClear(renderer);
        SDL_RenderPresent(renderer);
    }

    SDL_DestroyRenderer(renderer);
    SDL_DestroyWindow(window);

    SDL_Quit();

    return 0;
}

The commands:

# Installs SDL v2.0.12 to `subprojects/`
mkdir subprojects
meson wrap install sdl2
# Runs OK (1)
meson setup ./build
# Prints error (2)
meson compile -C ./build
(1) Output

The Meson build system
Version: 0.60.3
Source dir: C:\Users\Mark\Desktop\t
Build dir: C:\Users\Mark\Desktop\t\build
Build type: native build
Project name: t
Project version: undefined
C compiler for the host machine: ccache gcc (gcc 11.2.0 "gcc.exe (MinGW-W64 x86_64-posix-seh, built by Brecht Sander
C linker for the host machine: gcc ld.bfd 2.37
Host machine cpu family: x86_64
Host machine cpu: x86_64
Did not find pkg-config by name ‘pkg-config’
Found Pkg-config: NO
sdl2-config found: NO
Run-time dependency sdl2 found: NO (tried pkgconfig and config-tool)
Looking for a fallback subproject for the dependency sdl2
Downloading sdl2 source from https :// www. libsdl .org/release/SDL2-2.0.12.tar.gz
Download size: 5720162
Downloading: …
Downloading sdl2 patch from https :// wrapdb. mesonbuild .com/v2/sdl2_2.0.12-3/get_patch
Download size: 33375
Downloading: …

Executing subproject sdl2

sdl2| Project name: sdl2
sdl2| Project version: 2.0.12
sdl2| C compiler for the host machine: ccache gcc (gcc 11.2.0 "gcc.exe (MinGW-W64 x86_64-posix-seh, built by Brecht
sdl2| C linker for the host machine: gcc ld.bfd 2.37
sdl2| Library m found: YES
sdl2| Library dl found: YES
sdl2| Library pthread found: YES
sdl2| Has header “alloca.h” : NO
sdl2| Has header “sys/types.h” : YES
sdl2| Has header “stdio.h” : YES
sdl2| Has header “stdlib.h” : YES
sdl2| Has header “stdarg.h” : YES
sdl2| Has header “malloc.h” : YES
sdl2| Has header “memory.h” : YES
sdl2| Has header “string.h” : YES
sdl2| Has header “strings.h” : YES
sdl2| Has header “inttypes.h” : YES
sdl2| Has header “stdint.h” : YES
sdl2| Has header “ctype.h” : YES
sdl2| Has header “math.h” : YES
sdl2| Has header “iconv.h” : NO
sdl2| Has header “signal.h” : YES
sdl2| Has header “altivec.h” : NO
sdl2| Has header “pthread/np.h” : NO
sdl2| Has header “libudev.h” : NO
sdl2| Has header “dbus/dbus.h” : NO
sdl2| Has header “stdarg.h” : YES (cached)
sdl2| Has header “stddef.h” : YES
sdl2| Checking for function “malloc” : YES
sdl2| Checking for function “calloc” : YES
sdl2| Checking for function “realloc” : YES
sdl2| Checking for function “free” : YES
sdl2| Checking for function “alloca” : NO
sdl2| Checking for function “setenv” : NO
sdl2| Checking for function “setenv” : NO (cached)
sdl2| Checking for function “putenv” : YES
sdl2| Checking for function “unsetenv” : NO
sdl2| Checking for function “qsort” : YES
sdl2| Checking for function “abs” : YES
sdl2| Checking for function “bcopy” : NO
sdl2| Checking for function “memset” : YES
sdl2| Checking for function “memcpy” : YES
sdl2| Checking for function “memmove” : YES
sdl2| Checking for function “memcmp” : YES
sdl2| Checking for function “strlen” : YES
sdl2| Checking for function “strlcpy” : NO
sdl2| Checking for function “strlcat” : NO
sdl2| Checking for function “strdup” : YES
sdl2| Checking for function “_strrev” : YES
sdl2| Checking for function “_strupr” : YES
sdl2| Checking for function “_strlwr” : YES
sdl2| Checking for function “index” : NO
sdl2| Checking for function “rindex” : NO
sdl2| Checking for function “strchr” : YES
sdl2| Checking for function “strrchr” : YES
sdl2| Checking for function “strstr” : YES
sdl2| Checking for function “itoa” : YES
sdl2| Checking for function “_ltoa” : NO
sdl2| Checking for function “_uitoa” : NO
sdl2| Checking for function “_ultoa” : YES
sdl2| Checking for function “strtol” : YES
sdl2| Checking for function “strtoul” : YES
sdl2| Checking for function “_i64toa” : YES
sdl2| Checking for function “_uit64toa” : NO
sdl2| Checking for function “strtoll” : YES
sdl2| Checking for function “strtoull” : YES
sdl2| Checking for function “strtod” : YES
sdl2| Checking for function “atoi” : YES
sdl2| Checking for function “atof” : YES
sdl2| Checking for function “strcmp” : YES
sdl2| Checking for function “strncmp” : YES
sdl2| Checking for function “_stricmp” : YES
sdl2| Checking for function “strcasecmp” : YES
sdl2| Checking for function “_strnicmp” : YES
sdl2| Checking for function “strncasecmp” : YES
sdl2| Checking for function “vsscanf” : YES
sdl2| Checking for function “vsnprintf” : YES
sdl2| Checking for function “atan” : YES
sdl2| Checking for function “atan2” : YES
sdl2| Checking for function “acos” : YES
sdl2| Checking for function “asin” : YES
sdl2| Checking for function “ceil” : YES
sdl2| Checking for function “copysign” : YES
sdl2| Checking for function “cos” : YES
sdl2| Checking for function “cosf” : YES
sdl2| Checking for function “fabs” : YES
sdl2| Checking for function “floor” : YES
sdl2| Checking for function “log” : YES
sdl2| Checking for function “pow” : YES
sdl2| Checking for function “scalbn” : YES
sdl2| Checking for function “sin” : YES
sdl2| Checking for function “sinf” : YES
sdl2| Checking for function “sqrt” : YES
sdl2| Checking for function “fseeko” : YES
sdl2| Checking for function “fseeko64” : YES
sdl2| Checking for function “sigaction” : NO
sdl2| Checking for function “setjmp” : YES
sdl2| Checking for function “nanosleep” : YES
sdl2| Checking for function “sysconf” : NO
sdl2| Checking for function “sysctlbyname” : NO
sdl2| Checking for function “clock_gettime” : YES
sdl2| Checking for function “getpagesize” : NO
sdl2| Checking for function “mprotect” : NO
sdl2| Checking for function “pthread_setname_np” : YES
sdl2| Checking for function “pthread_set_name_np” : NO
sdl2| Checking if “M_PI” : compiles: NO
sdl2| Checking if “pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)” : compiles: YES
sdl2| Library winmm found: YES
sdl2| Library version found: YES
sdl2| Library imm32 found: YES
sdl2| Checking for size of “void*” : 8
sdl2| Found CMake: C:\Program Files\CMake\bin\cmake.EXE (3.22.1)
sdl2| Run-time dependency alsa found: NO (tried pkgconfig and cmake)
sdl2| Run-time dependency x11 found: NO (tried pkgconfig and cmake)
sdl2| Run-time dependency xi found: NO (tried pkgconfig and cmake)
sdl2| Run-time dependency xext found: NO (tried pkgconfig and cmake)
sdl2| Run-time dependency gl found: YES
sdl2| Run-time dependency xrandr found: NO (tried pkgconfig and cmake)
sdl2| Run-time dependency xinerama found: NO (tried pkgconfig and cmake)
sdl2| Library setupapi found: YES
sdl2| Build targets in project: 2
sdl2| Subproject sdl2 finished.

Dependency sdl2 from subproject subprojects/SDL2-2.0.12 found: YES 2.0.12
Build targets in project: 3

t undefined

Subprojects
sdl2: YES

Found ninja-1.10.2 at C:\ProgramData\chocolatey\bin\ninja.EXE

Links are intentionally filled with extra spaces to make this forum happy.

(2) Error message

ninja: Entering directory `C:/Users/Mark/Desktop/t/build’
[1/80] Compiling C object subprojects/SDL2-2.0.12/libsdl2.a.p/src_render_opengles2_SDL_render_gles2.c.obj
FAILED: subprojects/SDL2-2.0.12/libsdl2.a.p/src_render_opengles2_SDL_render_gles2.c.obj
“ccache” “gcc” “-Isubprojects\SDL2-2.0.12\libsdl2.a.p” “-Isubprojects\SDL2-2.0.12” “-I…\subprojects\SDL2-2.0.12” “-Isubprojects\SDL2-2.0.12\include” “-I…\subprojects\SDL2-2.0.12\include” “-I…\subprojects\SDL2-2.0.12\src\hidapi\hidapi” “-fdiagnostics-color=always” “-D_FILE_OFFSET_BITS=64” “-Wall” “-Winvalid-pch” “-g” -MD -MQ subprojects/SDL2-2.0.12/libsdl2.a.p/src_render_opengles2_SDL_render_gles2.c.obj -MF “subprojects\SDL2-2.0.12\libsdl2.a.p\src_render_opengles2_SDL_render_gles2.c.obj.d” -o subprojects/SDL2-2.0.12/libsdl2.a.p/src_render_opengles2_SDL_render_gles2.c.obj
“-c” …/subprojects/SDL2-2.0.12/src/render/opengles2/SDL_render_gles2.c
In file included from …/subprojects/SDL2-2.0.12/src/render/opengles2/SDL_render_gles2.c:27:
…\subprojects\SDL2-2.0.12\include/SDL_opengles2.h:35:10: fatal error: GLES2/gl2platform.h: No such file or directory
35 | #include <GLES2/gl2platform.h>
| ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
[2/80] Compiling C object subprojects/SDL2-2.0.12/libsdl2.a.p/src_render_opengles2_SDL_shaders_gles2.c.obj
FAILED: subprojects/SDL2-2.0.12/libsdl2.a.p/src_render_opengles2_SDL_shaders_gles2.c.obj
“ccache” “gcc” “-Isubprojects\SDL2-2.0.12\libsdl2.a.p” “-Isubprojects\SDL2-2.0.12” “-I…\subprojects\SDL2-2.0.12” “-Isubprojects\SDL2-2.0.12\include” “-I…\subprojects\SDL2-2.0.12\include” “-I…\subprojects\SDL2-2.0.12\src\hidapi\hidapi” “-fdiagnostics-color=always” “-D_FILE_OFFSET_BITS=64” “-Wall” “-Winvalid-pch” “-g” -MD -MQ subprojects/SDL2-2.0.12/libsdl2.a.p/src_render_opengles2_SDL_shaders_gles2.c.obj -MF “subprojects\SDL2-2.0.12\libsdl2.a.p\src_render_opengles2_SDL_shaders_gles2.c.obj.d” -o subprojects/SDL2-2.0.12/libsdl2.a.p/src_render_opengles2_SDL_shaders_gles2.c.obj “-c” …/subprojects/SDL2-2.0.12/src/render/opengles2/SDL_shaders_gles2.c
In file included from …/subprojects/SDL2-2.0.12/src/render/opengles2/SDL_shaders_gles2.c:26:
…\subprojects\SDL2-2.0.12\include/SDL_opengles2.h:35:10: fatal error: GLES2/gl2platform.h: No such file or directory
35 | #include <GLES2/gl2platform.h>
| ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
[10/80] Compiling C object subprojects/SDL2-2.0.12/libsdl2.a.p/src_render_direct3d_SDL_render_d3d.c.obj
FAILED: subprojects/SDL2-2.0.12/libsdl2.a.p/src_render_direct3d_SDL_render_d3d.c.obj
“ccache” “gcc” “-Isubprojects\SDL2-2.0.12\libsdl2.a.p” “-Isubprojects\SDL2-2.0.12” “-I…\subprojects\SDL2-2.0.12” “-Isubprojects\SDL2-2.0.12\include” “-I…\subprojects\SDL2-2.0.12\include” “-I…\subprojects\SDL2-2.0.12\src\hidapi\hidapi” “-fdiagnostics-color=always” “-D_FILE_OFFSET_BITS=64” “-Wall” “-Winvalid-pch” “-g” -MD -MQ subprojects/SDL2-2.0.12/libsdl2.a.p/src_render_direct3d_SDL_render_d3d.c.obj -MF “subprojects\SDL2-2.0.12\libsdl2.a.p\src_render_direct3d_SDL_render_d3d.c.obj.d” -o subprojects/SDL2-2.0.12/libsdl2.a.p/src_render_direct3d_SDL_render_d3d.c.obj “-c” …/subprojects/SDL2-2.0.12/src/render/direct3d/SDL_render_d3d.c
In file included from c:\users\mark\desktop\t\subprojects\sdl2-2.0.12\src\video\sdl_egl_c.h:28,
from c:\users\mark\desktop\t\subprojects\sdl2-2.0.12\src\video\windows\SDL_windowsopengles.h:29,
from c:\users\mark\desktop\t\subprojects\sdl2-2.0.12\src\video\windows\sdl_windowsvideo.h:47,
from …/subprojects/SDL2-2.0.12/src/render/direct3d/SDL_render_d3d.c:37:
…\subprojects\SDL2-2.0.12\include/SDL_egl.h:29:10: fatal error: EGL/egl.h: No such file or directory
29 | #include <EGL/egl.h>
| ^~~~~~~~~~~
compilation terminated.
ninja: build stopped: subcommand failed.

How can I fix the project to compile?