Jump to content
  • Advertisement
Sign in to follow this  
Zolcosmaster

undefined reference to 'SDL_SetVideoMode'

This topic is 4063 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to compile a simple test SDL program under MinGW in Windows. I get these errors:
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccYFbaaa.o(.text+0xeb):main.cpp: undefined reference to `SDL_SetVideoMode'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccYFbaaa.o(.text+0x102):main.cpp: undefined reference to `SDL_WM_SetCaption'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccYFbaaa.o(.text+0x347):main.cpp: undefined reference to `SDL_Flip'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccYFbaaa.o(.text+0x36d):main.cpp: undefined reference to `SDL_GetTicks'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccYFbaaa.o(.text+0x38e):main.cpp: undefined reference to `SDL_PollEvent'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccYFbaaa.o(.text+0x3d8):main.cpp: undefined reference to `SDL_Delay'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccYFbaaa.o(.text+0x3ea):main.cpp: undefined reference to `SDL_GetTicks'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccYFbaaa.o(.text+0x407):main.cpp: undefined reference to `SDL_FreeSurface'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccYFbaaa.o(.text+0x418):main.cpp: undefined reference to `SDL_FreeSurface'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccYFbaaa.o(.text+0x497):main.cpp: undefined reference to `SDL_Flip'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccSqcaaa.o(.text+0x4d):lib.cpp: undefined reference to `SDL_DisplayFormat'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccSqcaaa.o(.text+0x5e):lib.cpp: undefined reference to `SDL_FreeSurface'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccSqcaaa.o(.text+0xac):lib.cpp: undefined reference to `SDL_MapRGB'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccSqcaaa.o(.text+0xc5):lib.cpp: undefined reference to `SDL_SetColorKey'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccSqcaaa.o(.text+0xf3):lib.cpp: undefined reference to `SDL_UpperBlit'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccSqcaaa.o(.text+0x103):lib.cpp: undefined reference to `SDL_GetTicks'
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccSqcaaa.o(.text+0x110):lib.cpp: undefined reference to `SDL_GetTicks'
make: *** [all] Error 1

I've Googled this issue and it looks like the usual cause of this is not including the right libraries or the right compile options. This is my Makefile:
all:
	g++ -o Tutorial.exe -lmingw32 -lSDLmain -lSDL -lSDL_image main.cpp lib.cpp
clean:
	del Tutorial.exe

It all seems to be in order. I used the include statements:
#include "SDL/SDL.h"
#include "SDL/SDL_image.h"
#include <string>

I also looked through various tutorials and it looks like all the SDL library files are in the right place -- the folders lib, bin, and include (well, SDL\include). The code I'm using does compile and run under Linux with GCC. What's the deal here? [Edited by - Zolcosmaster on June 23, 2007 1:52:29 PM]

Share this post


Link to post
Share on other sites
Advertisement
I use the same order of linkage on all my SDL compilations and it works fine. Seems to me that you are missing the -L option to set the path to those libs.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kin the Pumpkin King
Is mingw32 the compiler or what?

If it's not and you're using Dev-C++, you have to add -lmingw32 to the parameters in the linker area. That's in Project Options.

Quote:
I'm trying to compile a simple test SDL program under MinGW in Windows.

Quote:
all:
g++ -o Tutorial.exe -lmingw32 -lSDLmain -lSDL -lSDL_image main.cpp lib.cpp
clean:
del Tutorial.exe


BTW, Dev-C++ uses MinGW.

Share this post


Link to post
Share on other sites
Why not install cygwin and use the sdl-config application? I can use the same makefile on Linux as I can with Windows with this method. You just have to download the SDL source code and build it after installing cygwin and the tool is available to you. It's really convenient. You can get the source here: http://www.libsdl.org/release/SDL-1.2.11.zip

Albeit somewhat generic, here's the sample makefile in case you're curious:

CC=g++
CFLAGS=-O2 -W -Wall -pedantic `sdl-config --cflags` -ggdb
#CFLAGS=-O2 -W -Wall -pedantic `sdl-config --cflags`
LIBS=`sdl-config --libs`

PROGRAM_NAME=binarytux

parser:
$(CC) $(CFLAGS) main.cpp input/input.cpp engine/engine.cpp engine/world/character.cpp engine/world/player.cpp engine/world/npc.cpp engine/world/world.cpp display/display.cpp error/error.cpp engine/timer.cpp -o $(PROGRAM_NAME) $(LIBS)

run:
./$(PROGRAM_NAME)

clean:
rm $(PROGRAM_NAME)

Share this post


Link to post
Share on other sites
Thanks for the advice, everyone.
I tried specifying the LIB directory and so on but still couldn't get it to work.
I was just using straight-up MinGW with the COMSPEC shell, no IDE.
Eventually I gave up trying to get it to work, and downloaded Dev-C++. Everything works now. I was going to start using Dev-C++ anyway, but I wanted to prove a point to myself first. I guess that doesn't matter anymore, though. I have what I need to compile a Windows version of my Linux SDL programs and that's all that is important.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!