2013-03-31 24 views
2

我有一個使用SDL作爲外部庫的項目。該項目使用_SDL_WM_SetCaption,_SDL_FillRect或_SDL_MapRGBA等函數。我告訴鏈接器包含兩個庫SDL.lib和SDLmain.lib,並告訴它在放置這些庫的文件夾中查找。我還用dumpbin.exe檢查了庫文件,並且函數在那裏。但是,它仍然不能編譯/鏈接?爲什麼?有人有主意嗎?未解決的外部符號,即使我認爲我正確鏈接(MSVC)

編輯:這裏是連接器/編譯器錯誤的輸出示例:



14>libtestd.lib(sdlgl.obj) : error LNK2019: unresolved external symbol _SDL_WM_SetCaption referenced in function "public: void __thiscall SDLGLEngine::SetTitle(char *)" ([email protected]@@[email protected]) 
14>libtestd.lib(sdlgl.obj) : error LNK2019: unresolved external symbol _SDL_FillRect referenced in function "public: bool __thiscall SDLGLEngine::Init(int,int,int,bool)" ([email protected]@@[email protected]) 
14>libtestd.lib(sdlgl.obj) : error LNK2019: unresolved external symbol _SDL_MapRGBA referenced in function "public: bool __thiscall SDLGLEngine::Init(int,int,int,bool)" ([email protected]@@[email protected]) 
14>libtestd.lib(sdlgl.obj) : error LNK2019: unresolved external symbol _SDL_SetVideoMode referenced in function "public: bool __thiscall SDLGLEngine::Init(int,int,int,bool)" ([email protected]@@[email protected]) 
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)" ([email protected]@@[email protected]) 
14>libtestd.lib(sdlgl.obj) : error LNK2019: unresolved external symbol _SDL_Quit referenced in function "public: bool __thiscall SDLGLEngine::Init(int,int,int,bool)" ([email protected]@@[email protected]) 
14>libtestd.lib(sdlgl.obj) : error LNK2019: unresolved external symbol _SDL_Init referenced in function "public: bool __thiscall SDLGLEngine::Init(int,int,int,bool)" ([email protected]@@[email protected]) 

+1

它們是否具有相同的編譯標誌?像-MT/-MD?你鏈接到調試或發佈版本? – gongzhitaao

+1

你是否從'_SDL_Init'或'SDL_Init'的代碼中調用方法? –

+0

嗯,我必須檢查SDL_Init ... – user2011985

回答

8

可能的原因:

  • 的sdl.lib和sdlmain.lib設置不添加到依賴列表
  • 它們的位置沒有被添加到鏈接器看起來的目錄列表中
  • 你沒有匹配32位和64位版本的庫。
相關問題