Visual Studio CMakeList.txt can't find SDL.dll file

41 views Asked by At

I'm trying to start an application with CMake on Windows. But i always get following error: The code cannot run because SDL3.dll was not found. A newistallation of the programm may fix the error.

This is the original (german): Die Ausführung des Codes kann nicht fortgesetzt werden, da SDL3.dll nicht gefunden wurde. Durch eine Neuinstallation des Programms kann das Problem möglicherweise behoben werden.

The thing I don't get the most, is that the cpp files don't throw errors and even link to the SDL-files. Means i can include the headers and if i Ctrl+Click on for example SDL_Init() i get linked to SDL.c file in which the init is defined. So it is basically working..?

# CMakeList.txt : CMake project for TowerDefence, include source and define
# project specific logic here.
#
cmake_minimum_required (VERSION 3.8)

# Enable Hot Reload for MSVC compilers if supported.
if (POLICY CMP0141)
  cmake_policy(SET CMP0141 NEW)
  set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()

project (TowerDefence)

add_subdirectory(lib/SDL EXCLUDE_FROM_ALL)


# Add source to this project's executable.
add_executable (TowerDefence "TowerDefence.cpp" "TowerDefence.h")

if (CMAKE_VERSION VERSION_GREATER 3.12)
  set_property(TARGET TowerDefence PROPERTY CXX_STANDARD 20)
endif()

# TODO: Add tests and install targets if needed.
target_link_libraries(TowerDefence PRIVATE SDL3::SDL3)

I use the CMake Template of Visual Studio and didn't change any settings.

Some ideas?

I tried all i found on the Internet Some of it: 1. file(COPY ${SOME_VAR} DESTINATION ${EXECUTABLE_OUTPUT_PATH}) -> No idea if i did it right. What is "SOME_VAR"?

2. set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}") set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}")

0

There are 0 answers