SDL3 CMake linkage problem undefined reference for SDL

107 views Asked by At

When trying to link SDL3 as git submodule I get many errors:

...
undefined reference to `SDL_DestroyWindow'
undefined reference to `SDL_Quit'
undefined reference to `SDL_Init'
undefined reference to `SDL_CreateWindowAndRenderer'
...

What am I missing?

Here is my CMakeLists.txt:

cmake_minimum_required(VERSION 3.5.0)

project(project VERSION 0.1.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)

add_subdirectory(extern/sdl)
include_directories(Inc)

add_executable(project Src/main.cpp)

target_include_directories(project PUBLIC extern/sdl/include)
target_link_directories(project PUBLIC SDL3::SDL3)

I'm using:

  • Windows 11 (But I'd like it to be compileable on any platform - Unix was easy for me to setup. Windows is causing problems)
  • gcc 11.4 (Cygwin)
  • SDL3 - I take main branch, but SDL2 or basically any other release was the same
  • CLion as the IDE (idk if that makes any difference)

UPDATE

After adding:

target_link_libraries(project PRIVATE SDL3::SDL3)

I get an error:

SDL_hidapi_windows.h:57:30: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'SDL_toupper_REAL'
57 | #define towupper    (wchar_t)SDL_toupper
0

There are 0 answers