SDL linking library [closed]

asked 2011-07-19 15:02:25 -0600

kmaroney gravatar image

updated 2014-01-28 17:10:04 -0600

ngrennan gravatar image

Having a little trouble linking SDL to an executable in ROS. Here is what I have in my CMakelist to link the library.

rosbuild_add_executable(testbla src/testing.cpp)
target_link_libraries(testbla SDL) 

This is resulting in an error at runtime, seg faulting. The cause has been traced back to the initialization.

SDL_Init(SDL_INIT_VIDEO);

The debugging reveals..

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff16c6468 in dlerror () from /lib/libdl.so.2
(gdb) bt
#0  0x00007ffff16c6468 in dlerror () from /lib/libdl.so.2
#1  0x00007ffff264b9b7 in SDL_LoadFunction () from /usr/lib/libSDL-1.2.so.0
#2  0x00007ffff264cc15 in ?? () from /usr/lib/libSDL-1.2.so.0
#3  0x00007ffff264d7c8 in ?? () from /usr/lib/libSDL-1.2.so.0
#4  0x00007ffff2654f36 in ?? () from /usr/lib/libSDL-1.2.so.0
#5  0x00007ffff2647cec in SDL_VideoInit () from /usr/lib/libSDL-1.2.so.0
#6  0x00007ffff261e7eb in SDL_InitSubSystem () from /usr/lib/libSDL-1.2.so.0
#7  0x00007ffff261e82f in SDL_Init () from /usr/lib/libSDL-1.2.so.0
#8  0x0000000000401bb4 in main (argc=<value optimized="" out="">, argv=0x0)
    at /home/mak1pal/ros/constrained_teleop/src/testing.cpp:53
(gdb) quit
A debugging session is active.

Any help is appreciated. Thanks.

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by kwc
close date 2012-02-29 07:50:08

Comments

Can you do this with a non ROS executable? I think this might be more of a SDL problem than a ROS problem.
tfoote gravatar image tfoote  ( 2011-07-19 17:11:56 -0600 )edit
Hi Tully, we did compile and link the same code outside of ROS and it worked perfectly. The non ROS code is available here: http://ias.cs.tum.edu/~pangerci/testing.cpp. We used the following command to compile and link: "g++ -o sdl testing.cpp -I/usr/include/SDL/ -L/usr/lib/ -lSDL"
dejanpan gravatar image dejanpan  ( 2011-07-20 11:26:50 -0600 )edit
Maybe two conflicting versions of a library are linked. This can happen if a ROS package you depend on has a statically linked version (e.g. using copied source files) and SDL links against the dynamic system library, or vice versa. Does the crash still occur if you have no depends in your manifest?
roehling gravatar image roehling  ( 2011-09-15 02:27:49 -0600 )edit
Maybe check the output of ldd to see which libraries are used at runtime.
LiMuBei gravatar image LiMuBei  ( 2011-11-28 22:55:36 -0600 )edit