ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

How to add SDL2 library in cmake

asked 2017-01-30 11:56:09 -0500

Cayero gravatar image

updated 2022-01-22 16:16:34 -0500

Evgeny gravatar image

Hi I would like to add SDL2 library with headers to cmake. How can do that?? I'm new in ROS. I've tried something like this

include ${SDL2_INCLUDE_DIRS}
include ${catkin_INCLUDE_DIRS}

Could anyone help me? I would be very grateful

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-08-11 08:05:15 -0500

lucasw gravatar image

updated 2018-08-11 08:32:08 -0500

I have an example here: There is very little ros in it other than using cmake within catkin and ros params and info messages.

The two problems I encountered (only trying the mixer library) were that newer versions of CMake don't like spaces at the end of lists of libraries and that SDL2_mixer doesn't have a cmake file to find it, though SDL2 itself does:

find_package(SDL2 REQUIRED)
# No FindSDL2_mixer.cmake in Ubuntu 16.04?
# find_package(SDL2_mixer REQUIRED)
# Use pkg-config instead
# Using an underscore like SDL2_mixer doesn't work
pkg_check_modules(SDL2mixer REQUIRED SDL2_mixer)


add_executable(sdl2_mixer src/sdl2_mixer.cpp)

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-01-30 11:56:09 -0500

Seen: 2,044 times

Last updated: Aug 11 '18