未解决的外部符号,即使我认为我正确链接(MSVC)

时间:2013-03-31 23:15:49

标签: c++ visual-studio-2010 linker sdl dynamic-linking

我有一个使用SDL作为外部库的项目。该项目使用_SDL_WM_SetCaption,_SDL_FillRect或_SDL_MapRGBA等函数。我已告诉链接器包含两个库SDL.lib和SDLmain.lib并告诉它查看放置这些库的文件夹。我还用dumpbin.exe检查了库文件,函数就在那里。但它仍然无法编译/链接?为什么?有人有什么想法吗?

edit:这是链接器/编译器错误的示例输出:



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)

1 个答案:

答案 0 :(得分:8)

可能的原因:

  • sdl.lib和sdlmain.lib设置未添加到依赖关系列表
  • 他们的位置未添加到链接器所在的目录列表
  • 您的32位和64位版本的库不匹配。