Ask Your Question

How to add SDL2 library in cmake

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

Cayero gravatar image

updated 2017-01-30 11:56:34 -0500

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


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

Seen: 1,211 times

Last updated: Aug 11 '18