Advertisement

SDL on linux

Started by March 11, 2004 11:36 PM
10 comments, last by eedok 20 years, 7 months ago
well I try to port my SDL stuff to linux, and I install the sdl-devel rpm, then when I got to compiler my programs I get a mass load of linker errors I run this command
gcc main.c -Os -std=c99 -otrainme -L/usr/X11R6/lib -I/usr/include/SDL -D_REENTRANT -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread 
then I get this output:
: undefined reference to `XFree''
/usr/lib/libSDL.a(SDL_x11wm.o)(.text+0x9ee): In function `X11_SetCaption'':
: undefined reference to `XSync''
/usr/lib/libSDL.a(SDL_x11wm.o)(.text+0xa40): In function `X11_IconifyWindow'':
: undefined reference to `XIconifyWindow''
/usr/lib/libSDL.a(SDL_x11wm.o)(.text+0xa56): In function `X11_IconifyWindow'':
: undefined reference to `XSync''
/usr/lib/libSDL.a(SDL_x11wm.o)(.text+0xabe): In function `X11_GrabInputNoLock'':
: undefined reference to `XUngrabPointer''
/usr/lib/libSDL.a(SDL_x11wm.o)(.text+0xad2): In function `X11_GrabInputNoLock'':
: undefined reference to `XUngrabKeyboard''
/usr/lib/libSDL.a(SDL_x11wm.o)(.text+0xaef): In function `X11_GrabInputNoLock'':
: undefined reference to `XUngrabPointer''
/usr/lib/libSDL.a(SDL_x11wm.o)(.text+0xb24): In function `X11_GrabInputNoLock'':
: undefined reference to `XGrabPointer''
/usr/lib/libSDL.a(SDL_x11wm.o)(.text+0xb49): In function `X11_GrabInputNoLock'':
: undefined reference to `XGrabKeyboard''
/usr/lib/libSDL.a(SDL_x11wm.o)(.text+0xb6d): In function `X11_GrabInputNoLock'':
: undefined reference to `XRaiseWindow''
/usr/lib/libSDL.a(SDL_x11wm.o)(.text+0xb93): In function `X11_GrabInputNoLock'':
: undefined reference to `XSync''
/usr/lib/libSDL.a(SDL_x11wm.o)(.text+0xc32): In function `unlock_display'':
: undefined reference to `XSync''
/usr/lib/libSDL.a(SDL_x11yuv.o)(.text+0x274): In function `X11_CreateYUVOverlay'':
: undefined reference to `XFree''
/usr/lib/libSDL.a(SDL_x11yuv.o)(.text+0x403): In function `X11_CreateYUVOverlay'':
: undefined reference to `XFree''
/usr/lib/libSDL.a(SDL_x11yuv.o)(.text+0x4bc): In function `X11_CreateYUVOverlay'':
: undefined reference to `XSetErrorHandler''
/usr/lib/libSDL.a(SDL_x11yuv.o)(.text+0x4db): In function `X11_CreateYUVOverlay'':
: undefined reference to `XShmAttach''
/usr/lib/libSDL.a(SDL_x11yuv.o)(.text+0x4f5): In function `X11_CreateYUVOverlay'':
: undefined reference to `XSync''
/usr/lib/libSDL.a(SDL_x11yuv.o)(.text+0x504): In function `X11_CreateYUVOverlay'':
: undefined reference to `XSetErrorHandler''
/usr/lib/libSDL.a(SDL_x11yuv.o)(.text+0x56b): In function `X11_CreateYUVOverlay'':
: undefined reference to `XFree''
/usr/lib/libSDL.a(SDL_x11yuv.o)(.text+0x5dc): In function `X11_CreateYUVOverlay'':
: undefined reference to `XFree''
/usr/lib/libSDL.a(SDL_x11yuv.o)(.text+0x7d3): In function `X11_DisplayYUVOverlay'':
: undefined reference to `XSync''
/usr/lib/libSDL.a(SDL_x11yuv.o)(.text+0x83e): In function `X11_FreeYUVOverlay'':
: undefined reference to `XShmDetach''
/usr/lib/libSDL.a(SDL_x11yuv.o)(.text+0x85d): In function `X11_FreeYUVOverlay'':
: undefined reference to `XFree''
/usr/lib/libSDL.a(Xv.o)(.text+0x25): In function `xv_close_display'':
: undefined reference to `XextRemoveDisplay''
/usr/lib/libSDL.a(Xv.o)(.text+0x54): In function `xv_find_display'':
: undefined reference to `XextCreateExtension''
/usr/lib/libSDL.a(Xv.o)(.text+0x72): In function `xv_find_display'':
: undefined reference to `XextFindDisplay''
/usr/lib/libSDL.a(Xv.o)(.text+0x9b): In function `xv_find_display'':
: undefined reference to `XextAddDisplay''
/usr/lib/libSDL.a(Xv.o)(.text+0x112): In function `xv_error_string'':
: undefined reference to `XGetErrorDatabaseText''
/usr/lib/libSDL.a(Xv.o)(.text+0x167): In function `SDL_XvQueryExtension'':
: undefined reference to `XMissingExtension''
/usr/lib/libSDL.a(Xv.o)(.text+0x19a): In function `SDL_XvQueryExtension'':
: undefined reference to `_XFlush''
/usr/lib/libSDL.a(Xv.o)(.text+0x1ca): In function `SDL_XvQueryExtension'':
: undefined reference to `_XReply''
/usr/lib/libSDL.a(Xv.o)(.text+0x2a6): In function `SDL_XvQueryAdaptors'':
: undefined reference to `XMissingExtension''
/usr/lib/libSDL.a(Xv.o)(.text+0x2df): In function `SDL_XvQueryAdaptors'':
: undefined reference to `_XFlush''
/usr/lib/libSDL.a(Xv.o)(.text+0x31e): In function `SDL_XvQueryAdaptors'':
: undefined reference to `_XReply''
/usr/lib/libSDL.a(Xv.o)(.text+0x394): In function `SDL_XvQueryAdaptors'':
: undefined reference to `_XRead''
/usr/lib/libSDL.a(Xv.o)(.text+0x682): In function `SDL_XvQueryEncodings'':
: undefined reference to `XMissingExtension''
/usr/lib/libSDL.a(Xv.o)(.text+0x6bb): In function `SDL_XvQueryEncodings'':
: undefined reference to `_XFlush''
/usr/lib/libSDL.a(Xv.o)(.text+0x6fa): In function `SDL_XvQueryEncodings'':
: undefined reference to `_XReply''
Looks like the X11 development libraries are missing. You have to install them.
[size="2"]I like the Walrus best.
Advertisement
I see you''ve listed the X lib directory in the library path, but you don''t seem to be linking against the X lib. Did you try adding -lX11 to the command line?
quote: Original post by SiCrane
I see you''ve listed the X lib directory in the library path, but you don''t seem to be linking against the X lib. Did you try adding -lX11 to the command line?

k did that and the number of linker errors went down by like 5000 but there''s still some linking errors that look something like this
here''s the command now:
gcc main.c -Os -std=c99 -otrainme -L/usr/X11R6/lib -I/usr/include/SDL -D_REENTRANT -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread -lX11 


/usr/lib/libSDL.a(SDL_x11video.o)(.text+0x946): In function `X11_VideoInit'':: undefined reference to `XShmQueryExtension''/usr/lib/libSDL.a(SDL_x11yuv.o)(.text+0x4db): In function `X11_CreateYUVOverlay'':: undefined reference to `XShmAttach''/usr/lib/libSDL.a(SDL_x11yuv.o)(.text+0x83e): In function `X11_FreeYUVOverlay'':: undefined reference to `XShmDetach''/usr/lib/libSDL.a(Xv.o)(.text+0x25): In function `xv_close_display'':: undefined reference to `XextRemoveDisplay''/usr/lib/libSDL.a(Xv.o)(.text+0x54): In function `xv_find_display'':: undefined reference to `XextCreateExtension''/usr/lib/libSDL.a(Xv.o)(.text+0x72): In function `xv_find_display'':: undefined reference to `XextFindDisplay''/usr/lib/libSDL.a(Xv.o)(.text+0x9b): In function `xv_find_display'':: undefined reference to `XextAddDisplay''/usr/lib/libSDL.a(Xv.o)(.text+0x167): In function `SDL_XvQueryExtension'':: undefined reference to `XMissingExtension''/usr/lib/libSDL.a(Xv.o)(.text+0x2a6): In function `SDL_XvQueryAdaptors'':: undefined reference to `XMissingExtension''/usr/lib/libSDL.a(Xv.o)(.text+0x682): In function `SDL_XvQueryEncodings'':: undefined reference to `XMissingExtension''/usr/lib/libSDL.a(Xv.o)(.text+0x9af): In function `SDL_XvPutVideo'':: undefined reference to `XMissingExtension''/usr/lib/libSDL.a(Xv.o)(.text+0xadf): In function `SDL_XvPutStill'':: undefined reference to `XMissingExtension''/usr/lib/libSDL.a(Xv.o)(.text+0xc0f): more undefined references to `XMissingExtension'' follow/usr/lib/libSDL.a(SDL_x11image.o)(.text+0x114): In function `try_mitshm'':: undefined reference to `XShmAttach''/usr/lib/libSDL.a(SDL_x11image.o)(.text+0x220): In function `X11_SetupImage'':: undefined reference to `XShmCreateImage''/usr/lib/libSDL.a(SDL_x11image.o)(.text+0x24a): In function `X11_SetupImage'':: undefined reference to `XShmDetach''/usr/lib/libSDL.a(SDL_x11image.o)(.text+0x3af): In function `X11_DestroyImage'':: undefined reference to `XShmDetach''/usr/lib/libSDL.a(SDL_x11image.o)(.text+0x721): In function `X11_MITSHMUpdate'':: undefined reference to `XShmPutImage''/usr/lib/libSDL.a(SDL_x11image.o)(.text+0x847): In function `X11_RefreshDisplay'':: undefined reference to `XShmPutImage''/usr/lib/libSDL.a(XF86VMode.o)(.text+0x24): In function `find_display'':: undefined reference to `XextCreateExtension''/usr/lib/libSDL.a(XF86VMode.o)(.text+0x42): In function `find_display'':: undefined reference to `XextFindDisplay''/usr/lib/libSDL.a(XF86VMode.o)(.text+0x6b): In function `find_display'':: undefined reference to `XextAddDisplay''/usr/lib/libSDL.a(XF86VMode.o)(.text+0x9d): In function `close_display'':: undefined reference to `XextRemoveDisplay''/usr/lib/libSDL.a(XF86VMode.o)(.text+0x13b): In function `SDL_XF86VidModeQueryVersion'':: undefined reference to `XMissingExtension''/usr/lib/libSDL.a(XF86VMode.o)(.text+0x26f): In function `SDL_XF86VidModeSetClientVersion'':: undefined reference to `XMissingExtension''/usr/lib/libSDL.a(XF86VMode.o)(.text+0x34b): In function `SDL_XF86VidModeSetGamma'':: undefined reference to `XMissingExtension''/usr/lib/libSDL.a(XF86VMode.o)(.text+0x49f): In function `SDL_XF86VidModeGetGamma'':: undefined reference to `XMissingExtension''/usr/lib/libSDL.a(XF86VMode.o)(.text+0x603): In function `SDL_XF86VidModeGetModeLine'':: undefined reference to `XMissingExtension''/usr/lib/libSDL.a(XF86VMode.o)(.text+0x898): more undefined references to `XMissingExtension'' follow/usr/lib/libSDL.a(XF86DGA2.o)(.text+0x25): In function `xdga_close_display'':: undefined reference to `XextRemoveDisplay''/usr/lib/libSDL.a(XF86DGA2.o)(.text+0x54): In function `SDL_xdga_find_display'':: undefined reference to `XextCreateExtension''/usr/lib/libSDL.a(XF86DGA2.o)(.text+0x72): In function `SDL_xdga_find_display'':: undefined reference to `XextFindDisplay''/usr/lib/libSDL.a(XF86DGA2.o)(.text+0x9b): In function `SDL_xdga_find_display'':: undefined reference to `XextAddDisplay''/usr/lib/libSDL.a(XF86DGA2.o)(.text+0xfd): In function `xdga_wire_to_event'':: undefined reference to `XMissingExtension''/usr/lib/libSDL.a(XF86DGA2.o)(.text+0x271): In function `SDL_XDGAQueryVersion'':: undefined reference to `XMissingExtension''/usr/lib/libSDL.a(XF86DGA2.o)(.text+0x3f1): In function `SDL_XDGASetClientVersion'':: undefined reference to `XMissingExtension''/usr/lib/libSDL.a(XF86DGA2.o)(.text+0x4d4): In function `SDL_XDGAOpenFramebuffer'':: undefined reference to `XMissingExtension''/usr/lib/libSDL.a(XF86DGA2.o)(.text+0x64d): In function `SDL_XDGACloseFramebuffer'':: undefined reference to `XMissingExtension''/usr/lib/libSDL.a(XF86DGA2.o)(.text+0x73f): more undefined references to `XMissingExtension'' follow/usr/lib/libSDL.a(Xinerama.o)(.text+0x24): In function `find_display'':: undefined reference to `XextCreateExtension''/usr/lib/libSDL.a(Xinerama.o)(.text+0x42): In function `find_display'':: undefined reference to `XextFindDisplay''/usr/lib/libSDL.a(Xinerama.o)(.text+0x6b): In function `find_display'':: undefined reference to `XextAddDisplay''/usr/lib/libSDL.a(Xinerama.o)(.text+0x9d): In function `close_display'':: undefined reference to `XextRemoveDisplay''/usr/lib/libSDL.a(Xinerama.o)(.text+0x13b): In function `SDL_XPanoramiXQueryVersion'':: undefined reference to `XMissingExtension''/usr/lib/libSDL.a(Xinerama.o)(.text+0x28b): In function `SDL_XPanoramiXGetState'':: undefined reference to `XMissingExtension''/usr/lib/libSDL.a(Xinerama.o)(.text+0x3b3): In function `SDL_XPanoramiXGetScreenCount'':: undefined reference to `XMissingExtension''/usr/lib/libSDL.a(Xinerama.o)(.text+0x4d7): In function `SDL_XPanoramiXGetScreenSize'':: undefined reference to `XMissingExtension''/usr/lib/libSDL.a(Xinerama.o)(.text+0x779): In function `SDL_XineramaQueryScreens'':: undefined reference to `XMissingExtension''collect2: ld returned 1 exit status

Sounds like you also need the X extensions library. (-lXext if I remember right.)
I don''t see why he needs to pass all those libraries if he is using only X11 and SDL.
[size="2"]I like the Walrus best.
Advertisement
WOW!!!! Thx SiCrane it works perfectly now
quote: Original post by eedok
[...]
I run this command
gcc main.c -Os -std=c99 -otrainme -L/usr/X11R6/lib -I/usr/include/SDL -D_REENTRANT -L/usr/lib -Wl,-rpath,/usr/lib -lSDL -lpthread  

[...]


This may be helpful in the future too:
gcc main.c $(WHATEVER_FLAGS_OR_OPTIONS_YOU_WANT) `sdl-config --cflags` `sdl-config --libs` -otrainme 


You can issue the following on the command line for more information:
sdl-config 

yes, always add `sdl-config --cflags --libs` instead of -lSDL, -l etc...

it makes it easier for cross-platform fun as well, when you move to OS X or another unix-alike.

remember, that character is the accent thingie on the tilde key, not the single quote.

Resist everyone
I am your only friend. Click here for more information. (MOVED)
Penguin Ninja!
I had to give up on using SDL in linux for video. Every time I compiled a program it ran like 100 times slower than the windows version. I wish I was exagerating about the 100 but I''m not(much). Everyone was like "dude I don''t have a problem", "Always worked for me." And I was like "Well woo hoo for you" Never did get to the bottom of it. So I gave up programing in Linux all together. Then I quit programing. Now I think I''ll pick it up again. Not with much SDL though. Keyboard was all wierd, and the mouse only test for one button as near as I can tell. I''m hoping to have better luck with the audio.
------------------------------------------------------------- neglected projects Lore and The KeepersRandom artwork

This topic is closed to new replies.

Advertisement