SDL3 undefined symbol WinMain

source code

#define SDL_MAIN_USE_CALLBACKS
#include <SDL3/SDL_main.h>
#include <SDL3/SDL_events.h>
#include <SDL3/SDL_init.h>
#include <SDL3/SDL.h>

SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv)
{
    if (!SDL_Init(SDL_INIT_VIDEO)) {
        return SDL_APP_FAILURE;
    }
    return SDL_APP_CONTINUE;
}

SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
{
    while (SDL_PollEvent(event)) {
        if(event->quit.type == SDL_EVENT_QUIT)
        {
            return SDL_APP_SUCCESS;
        }
    }
}
SDL_AppResult SDL_AppIterate(void* appstate)
{
    SDL_Delay(8);
}

void SDL_AppQuit(void *appstate, SDL_AppResult result)
{
}

log

$ meson compile
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: D:\msys64\clang64\bin/ninja.EXE
[1/1] Linking target xxxx.exe
FAILED: [code=1] xxxx.exe 
"cc"  -o LernVulkanInC.exe xxxx.exe.p/src_utils_list.c.obj xxxx.exe.p/src_vk_renderer.c.obj "-Wl,--start-group" "D:/msys64/clang64/lib/libvulkan-1.dll.a" "D:/msys64/clang64/lib/libSDL3.dll.a" "-mwindows" "-Wl,--subsystem,console" "-lkernel32" "-luser32" "-lgdi32" "-lwinspool" "-lshell32" "-lole32" "-loleaut32" "-luuid" "-lcomdlg32" "-ladvapi32" "-Wl,--end-group"  
ld.lld: error: undefined symbol: WinMain
>>> referenced by D:/W/B/src/mingw-w64/mingw-w64-crt/crt/crtexewin.c:66
>>>               libmingw32.a(lib64_libmingw32_a-crtexewin.o):(main)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

Try adding -municode to your compiler/linker command line. I suspect for some reason we’re building with UNICODE defined, so SDL is providing a “wWinMain” function instead of “WinMain”