Advertisement Jump to content
Sign in to follow this  

Problem with cmake and SDL2

This topic is 1661 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



I have a problem with cmake and SDL2.


While linking the binary i get massive error with undefined references to SDL functions, but i link libSDL2.a to the binary.


The CMakeLists.txt is:

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

set(exe TBD)



file(GLOB_RECURSE srcs Source/*.cpp)

add_executable(${exe} ${srcs})


target_link_libraries(${exe} glew32 opengl32 glu32 SDL2 SDL2main)

If i remove the SDL2 and SDL2main in the linker libraries i get exactly the same errors.


I hope someone can help me.


Kind regards


Share this post

Link to post
Share on other sites
First, posting the actual errors would be helpful.

Second, are you certain you are linking correctly like that? Usually with CMake I would expect to use FIND_PACKAGE with the appropriate parameters for the library and then use the variables set by finder (check their documentation).

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!