Open j4cobgarby opened 6 years ago
I think that target_link_libraries must be used with ${SDL2_LIBRARIES}
, as it does not only contain ${SDL2_LIBRARY}
but also ${SDL2MAIN_LIBRARY}
Same problem on linux and windows.
# SDL2
find_package(SDL2 REQUIRED)
if ( SDL2_FOUND )
list (APPEND WSJCPP_INCLUDE_DIRS ${SDL2_INCLUDE_DIRS})
list (APPEND WSJCPP_LIBRARIES ${SDL2_LIBRARIES})
endif( SDL2_FOUND )
Error:
o: undefined reference to symbol 'SDL_FreeSurface'
changing SDL2_LIBRARIES
to SDL2_LIBRARY
- was help me
When my CMakeLists.txt is this
I get the following linker error:
Whereas adding
SDL2
to thetarget_link_libraries
makes the program link properly. I'm not great at this sort of thing - why is this happening? Any idea? Shouldn't${SDL_LIBRARY}
be equivalent toSDL2
?Any help would be much appreciated, but I assume it's me being stupid, as opposed to the cmake script not being correct.