unresolved external symbol even though i think i am linking correctly (MSVC)

10,748

Possible reasons:

  • the sdl.lib and sdlmain.lib settings are not added to dependency list
  • their location was not added to the list of directories where the linker looks
  • you have mismatched 32 and 64 bit versions of the libraries.
Share:
10,748
ChrisC
Author by

ChrisC

Updated on June 05, 2022

Comments

  • ChrisC
    ChrisC almost 2 years

    i have a project that is using SDL as an external library. The project uses functions such as _SDL_WM_SetCaption, _SDL_FillRect or _SDL_MapRGBA. I have told the linker to include the two libraries SDL.lib and SDLmain.lib and have told it to look in the folder where these libraries are placed. I have also inspected the library files with dumpbin.exe and the functions are there. however, it still doesnt work compiling/linking? why? anyone have any ideas?

    edit: here is an example output of the linker/compiler error:

    
    
    14>libtestd.lib(sdlgl.obj) : error LNK2019: unresolved external symbol _SDL_WM_SetCaption referenced in function "public: void __thiscall SDLGLEngine::SetTitle(char *)" (?SetTitle@SDLGLEngine@@QAEXPAD@Z)
    14>libtestd.lib(sdlgl.obj) : error LNK2019: unresolved external symbol _SDL_FillRect referenced in function "public: bool __thiscall SDLGLEngine::Init(int,int,int,bool)" (?Init@SDLGLEngine@@QAE_NHHH_N@Z)
    14>libtestd.lib(sdlgl.obj) : error LNK2019: unresolved external symbol _SDL_MapRGBA referenced in function "public: bool __thiscall SDLGLEngine::Init(int,int,int,bool)" (?Init@SDLGLEngine@@QAE_NHHH_N@Z)
    14>libtestd.lib(sdlgl.obj) : error LNK2019: unresolved external symbol _SDL_SetVideoMode referenced in function "public: bool __thiscall SDLGLEngine::Init(int,int,int,bool)" (?Init@SDLGLEngine@@QAE_NHHH_N@Z)
    14>libtestd.lib(sdlgl.obj) : error LNK2019: unresolved external symbol _SDL_GL_SetAttribute referenced in function "public: bool __thiscall SDLGLEngine::Init(int,int,int,bool)" (?Init@SDLGLEngine@@QAE_NHHH_N@Z)
    14>libtestd.lib(sdlgl.obj) : error LNK2019: unresolved external symbol _SDL_Quit referenced in function "public: bool __thiscall SDLGLEngine::Init(int,int,int,bool)" (?Init@SDLGLEngine@@QAE_NHHH_N@Z)
    14>libtestd.lib(sdlgl.obj) : error LNK2019: unresolved external symbol _SDL_Init referenced in function "public: bool __thiscall SDLGLEngine::Init(int,int,int,bool)" (?Init@SDLGLEngine@@QAE_NHHH_N@Z)