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.

Recommended Posts

Hello,

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)

set(CMAKE_CXX_COMPILER g++)
set(CMAKE_C_COMPILER gcc)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include) link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../libs)

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

Fbhywn

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).

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 17
• 14
• 10
• 9
• 11
• Forum Statistics

• Total Topics
634096
• Total Posts
3015503
×