Page 1 of 1

Visual C++ SDL Linker Errors

Posted: Thu Oct 07, 2010 5:18 am
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.

Re: Visual C++ SDL Linker Errors

Posted: Thu Oct 07, 2010 7:34 am
by Ginto8
Are you providing the correct linker flags for the release build? That's the first thing that comes to mind for me.

Re: Visual C++ SDL Linker Errors

Posted: Thu Oct 07, 2010 7:41 am
by Milch
Are you 100% sure that you are linking the same libs in the same order?

Re: Visual C++ SDL Linker Errors

Posted: Thu Oct 07, 2010 5:04 pm
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.

Re: Visual C++ SDL Linker Errors

Posted: Thu Oct 07, 2010 5:18 pm
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