Visual C++ SDL Linker Errors

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Visual C++ SDL Linker Errors

Post by RandomDever »

I just made a program but I want to test it in Release Mode but every time I try to build it it gives me this:

Code: Select all

Linking...
game.obj : error LNK2001: unresolved external symbol _SDL_Init
game.obj : error LNK2001: unresolved external symbol _Mix_PlayChannelTimed
game.obj : error LNK2001: unresolved external symbol _Mix_HaltChannel
game.obj : error LNK2001: unresolved external symbol _SDL_RWFromFile
game.obj : error LNK2001: unresolved external symbol _SDL_FillRect
game.obj : error LNK2001: unresolved external symbol _Mix_LoadWAV_RW
game.obj : error LNK2001: unresolved external symbol _SDL_Delay
game.obj : error LNK2001: unresolved external symbol _Mix_FreeChunk
game.obj : error LNK2001: unresolved external symbol _SDL_MapRGB
game.obj : error LNK2001: unresolved external symbol _SDL_CreateRGBSurface
game.obj : error LNK2001: unresolved external symbol _Mix_OpenAudio
game.obj : error LNK2001: unresolved external symbol _SDL_Quit
GUI_VImgPanel.obj : error LNK2001: unresolved external symbol _SDL_UpperBlit
GUI_VImgPanel.obj : error LNK2001: unresolved external symbol _SDL_SetColorKey
input.obj : error LNK2001: unresolved external symbol _SDL_PollEvent
input.obj : error LNK2001: unresolved external symbol _SDL_GetKeyState
music.obj : error LNK2001: unresolved external symbol _Mix_Quit
music.obj : error LNK2001: unresolved external symbol _Mix_Init
music.obj : error LNK2001: unresolved external symbol _Mix_CloseAudio
text.obj : error LNK2001: unresolved external symbol _TTF_RenderText_Solid
text.obj : error LNK2001: unresolved external symbol _TTF_OpenFont
text.obj : error LNK2001: unresolved external symbol _TTF_CloseFont
text.obj : error LNK2001: unresolved external symbol _TTF_Init
text.obj : error LNK2001: unresolved external symbol _TTF_Quit
text.obj : error LNK2001: unresolved external symbol _SDL_FreeSurface
video.obj : error LNK2001: unresolved external symbol _SDL_WM_SetIcon
video.obj : error LNK2001: unresolved external symbol _SDL_DisplayFormat
video.obj : error LNK2001: unresolved external symbol _SDL_SetVideoMode
video.obj : error LNK2001: unresolved external symbol _SDL_WM_SetCaption
video.obj : error LNK2001: unresolved external symbol _SDL_ShowCursor
video.obj : error LNK2001: unresolved external symbol _SDL_Flip
video.obj : error LNK2001: unresolved external symbol _IMG_Load
MSVCRT.lib(crtexew.obj) : error LNK2001: unresolved external symbol _WinMain@16
C:\Users\Randomdever\Documents\Visual Studio 2008\Projects\HTGR_P1_A1\Release\HTGR_P1_A1.exe : fatal error LNK1120: 34 unresolved externals
It builds and runs fine in debug but not release.
Any help is GREATLY appreciated.
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: Visual C++ SDL Linker Errors

Post by Ginto8 »

Are you providing the correct linker flags for the release build? That's the first thing that comes to mind for me.
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
User avatar
Milch
Chaos Rift Junior
Chaos Rift Junior
Posts: 241
Joined: Sat Jul 11, 2009 5:55 am
Programming Language of Choice: C++
Location: Austria, Vienna

Re: Visual C++ SDL Linker Errors

Post by Milch »

Are you 100% sure that you are linking the same libs in the same order?
Follow me on twitter!
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Re: Visual C++ SDL Linker Errors

Post by RandomDever »

huh? Linker Flags? Please explain.

Edit: Never mind I fixed it. I found someone with a similar problem online.
All you need to do is:

Code: Select all

#pragma comment( lib, "SDL.lib" )
#pragma comment( lib, "SDLmain.lib" )
#pragma comment( lib, "SDL_image.lib" )
#pragma comment( lib, "SDL_ttf.lib" )
#pragma comment( lib, "SDL_mixer.lib" )
Another Edit: I never learned about what #pragma did so yeah.
Last edited by RandomDever on Thu Oct 07, 2010 5:21 pm, edited 2 times in total.
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Visual C++ SDL Linker Errors

Post by eatcomics »

Linker errors suck. And just go back and make sure you've linked all the SDL stuff the way you're supposed to
Image
Post Reply