在封装一个调用SDL库的类,编译时出现如下错误:
1>SdlCite.obj : error LNK2019: unresolved external symbol _SDL_CreateThread referenced in function "public: int __thiscall CSdlCite::SC_Init(void)" (?SC_Init@CSdlCite@@QAEHXZ)
1>SdlCite.obj : error LNK2019: unresolved external symbol _SDL_CreateWindowFrom referenced in function "public: int __thiscall CSdlCite::SC_Init(void)" (?SC_Init@CSdlCite@@QAEHXZ)
1>SdlCite.obj : error LNK2019: unresolved external symbol _SDL_SetWindowPosition referenced in function "public: int __thiscall CSdlCite::SC_Init(void)" (?SC_Init@CSdlCite@@QAEHXZ)
1>SdlCite.obj : error LNK2019: unresolved external symbol _SDL_SetWindowFullscreen referenced in function "public: int __thiscall CSdlCite::SC_Init(void)" (?SC_Init@CSdlCite@@QAEHXZ)
1>SdlCite.obj : error LNK2019: unresolved external symbol _SDL_PushEvent referenced in function "int __cdecl sfp_refresh_thread(void *)" (?sfp_refresh_thread@@YAHPAX@Z)
1>SdlCite.obj : error LNK2019: unresolved external symbol _SDL_CreateRenderer referenced in function "public: int __thiscall CSdlCite::SC_Init(void)" (?SC_Init@CSdlCite@@QAEHXZ)
1>SdlCite.obj : error LNK2019: unresolved external symbol _SDL_CreateTexture referenced in function "public: int __thiscall CSdlCite::SC_Init(void)" (?SC_Init@CSdlCite@@QAEHXZ)
1>SdlCite.obj : error LNK2019: unresolved external symbol _SDL_UpdateTexture referenced in function "public: int __thiscall CSdlCite::SC_UpdateData(void *,int)" (?SC_UpdateData@CSdlCite@@QAEHPAXH@Z)
1>SdlCite.obj : error LNK2019: unresolved external symbol _SDL_RenderClear referenced in function "public: int __thiscall CSdlCite::SC_UpdateData(void *,int)" (?SC_UpdateData@CSdlCite@@QAEHPAXH@Z)
1>SdlCite.obj : error LNK2019: unresolved external symbol _SDL_RenderCopy referenced in function "public: int __thiscall CSdlCite::SC_UpdateData(void *,int)" (?SC_UpdateData@CSdlCite@@QAEHPAXH@Z)
1>SdlCite.obj : error LNK2019: unresolved external symbol _SDL_RenderPresent referenced in function "public: int __thiscall CSdlCite::SC_UpdateData(void *,int)" (?SC_UpdateData@CSdlCite@@QAEHPAXH@Z)
1>SdlCite.obj : error LNK2019: unresolved external symbol _SDL_Delay referenced in function "int __cdecl sfp_refresh_thread(void *)" (?sfp_refresh_thread@@YAHPAX@Z)
1>SdlCite.obj : error LNK2019: unresolved external symbol _SDL_Init referenced in function "public: int __thiscall CSdlCite::SC_Init(void)" (?SC_Init@CSdlCite@@QAEHXZ)
1>D:\Code\Git_Space\ffmpeg sample\TestFfmpeg\Debug\TestFfmpeg.exe : fatal error LNK1120: 13 unresolved externals
error LNK2019,就是只声明了头文件,没有引用lib库的错误。修正过来:
#pragma comment(lib,"SDL2.lib")
#pragma comment(lib,"SDL2main.lib")