# Building SDL3 applications on Windows with CMake

**URL:** <https://discourse.libsdl.org/t/building-sdl3-applications-on-windows-with-cmake/66908>\
**Category:** Game Development\
**Created:** [March 28, 2026, 11:24pm UTC](https://discourse.libsdl.org/t/building-sdl3-applications-on-windows-with-cmake/66908 "2026-03-28T23:24:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edge-One](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/e/e99b99/32.png) [@Edge-One](https://discourse.libsdl.org/u/Edge-One)\
**Post date:** [March 28, 2026, 11:24pm UTC](https://discourse.libsdl.org/t/building-sdl3-applications-on-windows-with-cmake/66908/1 "2026-03-28T23:24:18Z")

</div>

Hi,

I can’t figure out how to build a basic SDL3 application

using CMake. Can anybody help?

Thanks.

---

<div class="post-metadata">

**Author:** ![8Observer8](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/8/bbe5ce/32.png) [@8Observer8](https://discourse.libsdl.org/u/8Observer8)\
**Post date:** [March 29, 2026, 12:13pm UTC](https://discourse.libsdl.org/t/building-sdl3-applications-on-windows-with-cmake/66908/2 "2026-03-29T12:13:56Z")

</div>

Hello!

Do you have MinGW or MSVC installed? I prefer MinGW. You can download it here: [https://winlibs.com/](https://winlibs.com/) I have installed the MinGW GCC 13.1 version because Qt 6.10 uses it. I use Win64 version without LLVM:

 ![image](https://discourse.libsdl.org/uploads/default/original/2X/e/efadc88f0e90ef8423777d931046d5a554d789ff.png)

Or do you prefer Visual Studio? If you like MinGW you can use Qt Creator + CMake + MinGW (but MSVC can be used with Qt Creator too). You can download the Qt Creator installer separated from Qt from [GitHub Releases](https://github.com/qt-creator/qt-creator/releases)

You can create an empty folder for your project. Create the `CMakeLists.txt` file inside your project folder. Create the `src` folder with the `main.c` or `main.cpp` inside it.

CMakeLists.txt

```bash
cmake_minimum_required(VERSION 3.21)
project(example-sdl3-c)
 
# Set the C standard
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED ON)
 
# Set the name of the future application (in Windows this will be app.exe, 
# while for the web it would be app.js / app.wasm)
add_executable(app)
 
# Specify the exact location of the library configuration files
# The variable name must strictly follow the pattern: LibraryName_DIR
set(SDL3_DIR "C:/libs/SDL3-devel-3.4.2-mingw/lib/cmake/SDL3")
 
# Add the source code to the project
target_sources(app
    PRIVATE
    src/main.c
)
 
# Check for the presence of libraries in the system
# If they are not found, CMake will abort the configuration with an error
# REQUIRED means the package is mandatory for the build
find_package(SDL3 REQUIRED)
 
# Link the libraries to our application
target_link_libraries(app PRIVATE SDL3::SDL3)

```

You should download to download two archives: `SDL3-devel-x.x.x-mingw.zip` and `SDL3-x.x.x-win32-x64.zip` here: [GitHub Release](https://github.com/libsdl-org/SDL/releases). Unzip these folder somewhere, for example, in the `C:/libs` folder. Add `SDL3-x.x.x-win32-x64/bin` to Path (here is the `SDL3.dll` located)

I moved the x64 version of `SDL3-devel` on one level up:

 ![image](https://discourse.libsdl.org/uploads/default/original/2X/8/87cc605f8245d8ac57d3dc19a2ff7471552ed1f8.png)

Change the following path for your own in the `CMakeLists.txt`:

```bash
set(SDL3_DIR "C:/libs/SDL3-devel-3.4.2-mingw/lib/cmake/SDL3")

```

Download some example for test. For example, use the official example `01-clear`: [clear.c](https://github.com/libsdl-org/SDL/blob/main/examples/renderer/01-clear/clear.c). Copy this code to your `src/main.c` file.

Open CMD in the your project folder (where `CMakeLists.txt` is located) and type commands:

```bash
> cmake -G "MinGW Makefiles" -S . -B dist/win -DCMAKE_BUILD_TYPE=Debug
> cd dist\win
> cmake --build .
> app.exe

```

I have created three bat files to configure, built, and run EXE:

config-exe.bat

```bash
cmake -G "MinGW Makefiles" -S . -B dist/win ^
-DCMAKE_BUILD_TYPE=Debug

```

build-exe.bat

```bash
cd dist\win
cmake --build .
cd ..\..

```

run-exe.bat

```bash
dist\win\app

```

I can configure, build, and run EXE by these commands:

```auto
> config-exe
> build-exe
> run-exe

```

You can run Qt Creator and open your project in this IDE. Select `File` \> `Open File or Project...` and browse to your `CMakeLists.txt`. You can set breakpoints in Qt Creator and debug your project in step-by-step mode.

P.S. Qt Creator requires ~500 MB but Visual Studio requires much more. Maybe be you have a lot of free space on your SSD and you do not care about the space. But just in case.

---

<div class="post-metadata">

**Author:** ![Edge-One](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/e/e99b99/32.png) [@Edge-One](https://discourse.libsdl.org/u/Edge-One)\
**Post date:** [April 21, 2026, 6:53pm UTC](https://discourse.libsdl.org/t/building-sdl3-applications-on-windows-with-cmake/66908/3 "2026-04-21T18:53:38Z")

</div>

Thanks this is exactly what I needed, funny thing though, I’m actually using CLoin community version.😁

---

<div class="post-metadata">

**Author:** ![krapp](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/krapp/32/4747_2.png) [@krapp](https://discourse.libsdl.org/u/krapp)\
**Post date:** [April 24, 2026, 2:13pm UTC](https://discourse.libsdl.org/t/building-sdl3-applications-on-windows-with-cmake/66908/4 "2026-04-24T14:13:08Z")

</div>

This is old but I thought I might as well post my project structure and CMake config since I’m using Windows and it was a pain for me to figure out.

I download the development versions of SDL (for vs in my case) and put them in a /vendored path relative to your project root. I also put /src, /include and /assets here so the structure looks like:

- /project
  - /assets (images, fonts, audio, etc)
  - /build (where the actual build happens)
  - /vendored (third party libraries)
  - /src (application source)
  - /include (application includes)

- CMakeLists.txt
- build.cmd

A basic working CMake script is provided here:

```auto
set(PROJECT Test)
project(${PROJECT} C)

set(CMAKE_C_COMPILER "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.44.35207/bin/Hostx64/x64/")

set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_BUILD_TYPE "Release")
set(ARCH "x64")

set(PROJECT_ROOT "${CMAKE_CURRENT_LIST_DIR}")
set(PROJECT_SRC "${PROJECT_ROOT}/src")
set(PROJECT_INC "${PROJECT_ROOT}/include")
set(PROJECT_ASSETS "${PROJECT_ROOT}/assets")
set(VENDORED "${PROJECT_ROOT}/vendored")

#copy and paste this for other SDL libraries, since they
#all have the same path structure
set(SDL3_VERSION "3.4.4")
set(SDL3_LIBRARY "${VENDORED}/SDL3-${SDL3_VERSION}/lib/${ARCH}")
set(SDL3_INCLUDE_DIR "${VENDORED}/SDL3-${SDL3_VERSION}/include")

set(MAIN "${PROJECT_SRC}/main.c")

add_executable(${PROJECT} ${MAIN}) 

set(PROJECT_SOURCE_FILES ${MAIN})
target_link_libraries(${PROJECT} "${SDL3_LIBRARY}/SDL3.lib")

#add the dlls to the build path.
file(GLOB_RECURSE PROJECT_DLLS "${SDL3_LIBRARY}/SDL3.dll")
add_custom_command(TARGET ${PROJECT} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_DLLS} "$<TARGET_FILE_DIR:${PROJECT}>")

#add assets to the build path
add_custom_command(TARGET ${PROJECT} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_ASSETS} "$<TARGET_FILE_DIR:${PROJECT}>/assets")

```

then run CMake (I use Powershell:)

`start powershell -noexit -command cmake -S . -B build`

---

<div class="post-metadata">

**Author:** ![8Observer8](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/8/bbe5ce/32.png) [@8Observer8](https://discourse.libsdl.org/u/8Observer8)\
**Post date:** [April 27, 2026, 10:00am UTC](https://discourse.libsdl.org/t/building-sdl3-applications-on-windows-with-cmake/66908/5 "2026-04-27T10:00:40Z")

</div>

> [@Edge-One](#):
>
> I’m actually using CLoin community version.

Me too. At first you can complete the following steps:

 ![image](https://discourse.libsdl.org/uploads/default/original/2X/8/8e63cbc8980348ce54773a8ae225dc5f899e82d5.png)
