Undifines reference errors in Dev-C++

Started by
5 comments, last by SiCrane 16 years, 1 month ago
Hi there, any help on this would be really appreciated....I am trying to compile some simple code on Dev-C++ but are getting lots of Linker errors. Here are a few lines from the compiler: [Linker error] undefined reference to `IMG_Load' [Linker error] undefined reference to `Mix_LoadMUS' [Linker error] undefined reference to `Mix_LoadWAV_RW' [Linker error] undefined reference to `TTF_Quit' [Linker error] undefined reference to `Mix_PlayChannelTimed' I have the Libraries properly in place, and have put this: -lmingw32 -lSDLmain -lSDL into the project options under parameters, Linker. Anyone know what I'm doing wrong here? Thanks very much.
Advertisement
Those errors indicate that you're using functions from SDL_Image, SDL_ttf and SDL_mixer, but you aren't linking against those libraries. Add the libraries to your linker settings.
You need to add -lSDL_mixer, -lSDL_ttf and -lSDL_image to the libraries section. -lSDL only includes the main SDL library. You may also need to download those libraries if you don't already have them.
Thanks very much, that's sorted it! There is just one more error I'm gettong which is this:

C:\Documents and Settings\Desktop\Tom TD Dev Proj\Makefile.win [Build Error] ["Tom] Error 1

I think it relates to the directoris of certain files but as long as every file associated with your project is in the same folder, the build should work right?

Thanks
I have just also looked at the compile log which says this:

Compiler: Default compiler
Building Makefile: "C:\Documents and Settings\Tim\Desktop\Tom TD Dev Proj\Makefile.win"
Executing make...
make.exe -f "C:\Documents and Settings\Tim\Desktop\Tom TD Dev Proj\Makefile.win" all
g++.exe Untitled1.o -o "Tom TD Dev Proj.exe" -L"C:/Dev-Cpp/lib" -mwindows -lmingw32 -lSDLmain -lSDL SDL_Image SDL_ttf SDL_mixer

g++.exe: SDL_Image: No such file or directory
g++.exe: SDL_ttf: No such file or directory
g++.exe: SDL_mixer: No such file or directory

make.exe: *** ["Tom] Error 1

Execution terminated

Any help would be much appreciated, Thanks.
Browse to the folder C:/Dev-Cpp/lib. Can you see SDL_ttf, SDL_mixer and SDL_image library files there (they may have the extension .a or .lib). If not, you'll need to follow the advice you got here to retrieve them.
in your linker settings

SDL_Image SDL_ttf SDL_mixer

should be

-lSDL_Image -lSDL_ttf -lSDL_mixer

This topic is closed to new replies.

Advertisement