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

## Recommended Posts

i have some problems when compiling/linking (on windows with DevC++) my SDL project which i wrote in linux. Does anyone have an idea on what i need to add in the makefile so that i won't get these errors?
  [Linker error] undefined reference to SDL_GetError'
[Linker error] undefined reference to SDL_SetModuleHandle'


i am using my linux makefile which i compiled (converted) to windows using devc++.

##### Share on other sites
Do you have it setup to link everything properly? I just dug up an old backup CD with some crap from when I was tinkering with SDL in linux, and found this in the makefiles:

LDFLAGS = sdl-config --libs

Looks like that's a script that gets installed with the SDL libs to make it less of a pain in the ass to figure out where to point it. Hope this helps!

##### Share on other sites
Whoops sorry, I completely missed your question haha. I thought you were trying to get it to work in linux.

In Dev-C++, just make sure you set it up to point at the right 'lib' directory (where you installed your SDL stuff).

I do have this in another makefile (this one is for Dev-C++):

DEVPATH="C:\Dev-C++"CFLAGS=-s -lmingw32 -lSDLmain -lSDL -IC:\$(DEVPATH)\INCLUDE\ -IC:\$(DEVPATH)\INCLUDE\$(GPP) -IC:\$(DEVPATH)\INCLUDE\ -LC:\$(DEVPATH)\LIB\ -BC:\$(DEVPATH)\BIN\

##### Share on other sites

i think it points to the includes because it doesn't give errors when linking SDL_gfx, SDL_image or SDL_ttf

if it helpes here is the win version of the makefile

# Project: Asteroids# Makefile created by Dev-C++ 4.9.9.2CPP  = g++.exe -D__DEBUG__CC   = gcc.exe -D__DEBUG__WINDRES = windres.exeRES  = OBJ  = Asteroids.o Input.o SDLCharacter.o SDLGraphics.o SDLText.o SDLTimer.o $(RES)LINKOBJ = Asteroids.o Input.o SDLCharacter.o SDLGraphics.o SDLText.o SDLTimer.o$(RES)LIBS =  -L"D:/Dev-Cpp/lib" -lmingw32 -lSDL -lSDLmain -lSDL_ttf -lSDL_image -lSDL_gfx  -g3 INCS =  -I"D:/Dev-Cpp/include" CXXINCS =  -I"D:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"D:/Dev-Cpp/include/c++/3.4.2/backward"  -I"D:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"D:/Dev-Cpp/include/c++/3.4.2"  -I"D:/Dev-Cpp/include" BIN  = Asteroids.exeCXXFLAGS = $(CXXINCS) -g3CFLAGS =$(INCS)   -g3RM = rm -f.PHONY: all all-before all-after clean clean-customall: all-before Asteroids.exe all-afterclean: clean-custom	${RM}$(OBJ) $(BIN)$(BIN): $(OBJ)$(CPP) $(LINKOBJ) -o "Asteroids.exe"$(LIBS)Asteroids.o: Asteroids.cpp	$(CPP) -c Asteroids.cpp -o Asteroids.o$(CXXFLAGS)Input.o: Input.cpp	$(CPP) -c Input.cpp -o Input.o$(CXXFLAGS)SDLCharacter.o: SDLCharacter.cpp	$(CPP) -c SDLCharacter.cpp -o SDLCharacter.o$(CXXFLAGS)SDLGraphics.o: SDLGraphics.cpp	$(CPP) -c SDLGraphics.cpp -o SDLGraphics.o$(CXXFLAGS)SDLText.o: SDLText.cpp	$(CPP) -c SDLText.cpp -o SDLText.o$(CXXFLAGS)SDLTimer.o: SDLTimer.cpp	$(CPP) -c SDLTimer.cpp -o SDLTimer.o$(CXXFLAGS)

EDIT: typos

##### Share on other sites
This is a long shot, but try swapping the orders of -lSDL and -lSDLmain. I googled, and found that to work for some people.

cheers

##### Share on other sites
aparently that work out...though very weird... thanks a lot :).