3

I am making a 64-bit game on Windows with SDL3, CMake and C++. I have managed, using my CMakeLists.txt, to dynamically link my program with SDL3. I am using the MinGW-w64 C++ Compiler, and I do not want the user to install SDL3.

My CMakeLists.txt is this:

cmake_minimum_required(VERSION 3.20)
project(space_adventure CXX)
set(CMAKE_PREFIX_PATH "C:/sdl3")
find_package(SDL3 REQUIRED CONFIG)
file(GLOB_RECURSE "sources" "src/*.cpp")
add_executable(space_adventure ${sources})
target_link_libraries(space_adventure PRIVATE SDL3::SDL3)

And I have attempted this:

cmake_minimum_required(VERSION 3.20)
project(space_adventure CXX)
set(CMAKE_PREFIX_PATH "C:/sdl3")
find_package(SDL3-static REQUIRED CONFIG)
file(GLOB_RECURSE "sources" "src/*.cpp")
add_executable(space_adventure ${sources})
target_link_libraries(space_adventure PRIVATE SDL3::SDL3-static)

I received this error when trying the second one:

CMake Error at CMakeLists.txt:5 (find_package):
 By not providing "FindSDL3-static.cmake" in CMAKE_MODULE_PATH this project
 has asked CMake to find a package configuration file provided by
 "SDL3-static", but CMake did not find one.
 Could not find a package configuration file provided by "SDL3-static" with
 any of the following names:
 SDL3-staticConfig.cmake
 sdl3-static-config.cmake
 Add the installation prefix of "SDL3-static" to CMAKE_PREFIX_PATH or set
 "SDL3-static_DIR" to a directory containing one of the above files. If
 "SDL3-static" provides a separate development package or SDK, be sure it
 has been installed.

I assume I have installed the wrong package. Namely, I installed and unzipped SDL3-3.2.28-win32-x86.zip from release 3.2.28 into C:/SDL3, which is a pre-built package. Should I use SDL3-devel-3.2.28-mingw.tar.gz? As I believe it is designed for the MinGW-w64 C++ compiler, this could be a solution. However I'm not quite sure.

asked Dec 9, 2025 at 15:11
4
  • 1
    If you are using MinGW I recommend that you use msys2 (which includes the compiler and thousands of open source packages in its package management) and have pacman install the ucrt64 version: https://packages.msys2.org/packages/mingw-w64-ucrt-x86_64-sdl3 the install instructions are in the middle of the page: pacman -S mingw-w64-ucrt-x86_64-sdl3 Commented Dec 9, 2025 at 15:23
  • @drescherjm Ok thanks! I installed msys2 and sdl3 and stuff and it now works! Commented Dec 9, 2025 at 18:27
  • 1
    I believe this is the best MinGW experience. For msvc I use vcpkg in manifest mode however that isn't always easy because packages fail to build often and it also requires more work than msys2. Commented Dec 9, 2025 at 18:46
  • 4
    While the solution has already been found, I'd like to add that you can always build the library from source. SDL uses CMake as its build system and provides many configuration options to enable or disable specific components. After building it, you can link to your static library directly using target_link_libraries and point to the static .a file you compiled, along with using target_include_directories to provide the header paths. Commented Dec 10, 2025 at 3:30

1 Answer 1

1

If you are using MinGW I recommend that you use msys2 (which includes the compiler and thousands of open source packages in its package management) and have pacman install the ucrt64 version: https://packages.msys2.org/packages/mingw-w64-ucrt-x86_64-sdl3 the install instructions are in the middle of the page: pacman -S mingw-w64-ucrt-x86_64-sdl3

This question can help you install msys2: How can I install MinGW-w64 and MSYS2?

answered Dec 12, 2025 at 21:23
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.