我的项目中SDL2的链接器错误

时间:2016-08-23 20:35:00

标签: c++ opengl linker-errors sdl-2

我使用CMake和Code :: Blocks从源代码构建SDL2,并尝试将我自己的项目源链接到以下静态库:

libSDL2.a
libSDL2main.a
OpenGL32.lib

这三个库包含在名为%libdir%的目录中(我正在使用Batch作为命令)。

我从Code :: Blocks构建中获得了libSDL2和libSDL2main。我从Windows目录中获取了OpenGL32,虽然我很久以前就找到了它,所以我无法回想起确切的位置。我使用了以下命令:

g++ *.o -L%libDir% -lOpenGL32 -lSDL2main -lSDL -o "output.exe"

以下是日志,我该如何纠正这些错误?:

projectdir\lib/libSDL2.a(SDL_windows.c.obj): In function `WIN_CoInitialize':
sdlsrc/core/windows/SDL_windows.c:73: undefined reference to `CoInitializeEx@8'
sdlsrc/core/windows/SDL_windows.c:75: undefined reference to `CoInitializeEx@8'
projectdir\lib/libSDL2.a(SDL_windows.c.obj): In function `WIN_CoUninitialize':
sdlsrc/core/windows/SDL_windows.c:92: undefined reference to `CoUninitialize@0'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_SetupAPI':
sdlsrc/video/windows/SDL_windowskeyboard.c:617: undefined reference to `ImmGetIMEFileNameA@12'
sdlsrc/video/windows/SDL_windowskeyboard.c:630: undefined reference to `ImmGetContext@4'
sdlsrc/video/windows/SDL_windowskeyboard.c:633: undefined reference to `ImmReleaseContext@8'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_GetId':
sdlsrc/video/windows/SDL_windowskeyboard.c:551: undefined reference to `ImmGetIMEFileNameA@12'
sdlsrc/video/windows/SDL_windowskeyboard.c:566: undefined reference to `GetFileVersionInfoSizeA@8'
sdlsrc/video/windows/SDL_windowskeyboard.c:570: undefined reference to `GetFileVersionInfoA@16'
sdlsrc/video/windows/SDL_windowskeyboard.c:571: undefined reference to `VerQueryValueA@16'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `UIElementSink_QueryInterface@12':
sdlsrc/video/windows/SDL_windowskeyboard.c:1013: undefined reference to `IID_IUnknown'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IPPASink_QueryInterface@12':
sdlsrc/video/windows/SDL_windowskeyboard.c:1119: undefined reference to `IID_IUnknown'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `UILess_GetCandidateList':
sdlsrc/video/windows/SDL_windowskeyboard.c:984: undefined reference to `SysFreeString@4'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_ClearComposition':
sdlsrc/video/windows/SDL_windowskeyboard.c:683: undefined reference to `ImmGetContext@4'
sdlsrc/video/windows/SDL_windowskeyboard.c:687: undefined reference to `ImmNotifyIME@16'
sdlsrc/video/windows/SDL_windowskeyboard.c:691: undefined reference to `ImmNotifyIME@16'
sdlsrc/video/windows/SDL_windowskeyboard.c:692: undefined reference to `ImmReleaseContext@8'
sdlsrc/video/windows/SDL_windowskeyboard.c:689: undefined reference to `ImmSetCompositionStringW@24'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_Disable':
sdlsrc/video/windows/SDL_windowskeyboard.c:364: undefined reference to `ImmAssociateContext@8'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `UIElementSink_BeginUIElement@12':
sdlsrc/video/windows/SDL_windowskeyboard.c:1051: undefined reference to `SysFreeString@4'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `UIElementSink_UpdateUIElement@8':
sdlsrc/video/windows/SDL_windowskeyboard.c:1078: undefined reference to `SysFreeString@4'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_Init':
sdlsrc/video/windows/SDL_windowskeyboard.c:309: undefined reference to `CoCreateInstance@20'
sdlsrc/video/windows/SDL_windowskeyboard.c:323: undefined reference to `ImmGetContext@4'
sdlsrc/video/windows/SDL_windowskeyboard.c:324: undefined reference to `ImmReleaseContext@8'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `UILess_SetupSinks':
sdlsrc/video/windows/SDL_windowskeyboard.c:1192: undefined reference to `CoCreateInstance@20'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_ClearComposition':
sdlsrc/video/windows/SDL_windowskeyboard.c:683: undefined reference to `ImmGetContext@4'
sdlsrc/video/windows/SDL_windowskeyboard.c:687: undefined reference to `ImmNotifyIME@16'
sdlsrc/video/windows/SDL_windowskeyboard.c:691: undefined reference to `ImmNotifyIME@16'
sdlsrc/video/windows/SDL_windowskeyboard.c:692: undefined reference to `ImmReleaseContext@8'
sdlsrc/video/windows/SDL_windowskeyboard.c:689: undefined reference to `ImmSetCompositionStringW@24'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_GetId':
sdlsrc/video/windows/SDL_windowskeyboard.c:551: undefined reference to `ImmGetIMEFileNameA@12'
sdlsrc/video/windows/SDL_windowskeyboard.c:566: undefined reference to `GetFileVersionInfoSizeA@8'
sdlsrc/video/windows/SDL_windowskeyboard.c:570: undefined reference to `GetFileVersionInfoA@16'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_GetReadingString':
sdlsrc/video/windows/SDL_windowskeyboard.c:423: undefined reference to `ImmGetContext@4'
sdlsrc/video/windows/SDL_windowskeyboard.c:498: undefined reference to `ImmReleaseContext@8'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_GetId':
sdlsrc/video/windows/SDL_windowskeyboard.c:571: undefined reference to `VerQueryValueA@16'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_Quit':
sdlsrc/video/windows/SDL_windowskeyboard.c:378: undefined reference to `ImmAssociateContext@8'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_Enable':
sdlsrc/video/windows/SDL_windowskeyboard.c:349: undefined reference to `ImmAssociateContext@8'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_ClearComposition':
sdlsrc/video/windows/SDL_windowskeyboard.c:683: undefined reference to `ImmGetContext@4'
sdlsrc/video/windows/SDL_windowskeyboard.c:687: undefined reference to `ImmNotifyIME@16'
sdlsrc/video/windows/SDL_windowskeyboard.c:691: undefined reference to `ImmNotifyIME@16'
sdlsrc/video/windows/SDL_windowskeyboard.c:692: undefined reference to `ImmReleaseContext@8'
sdlsrc/video/windows/SDL_windowskeyboard.c:689: undefined reference to `ImmSetCompositionStringW@24'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_Disable':
sdlsrc/video/windows/SDL_windowskeyboard.c:364: undefined reference to `ImmAssociateContext@8'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `WIN_SetTextInputRect':
sdlsrc/video/windows/SDL_windowskeyboard.c:202: undefined reference to `ImmGetContext@4'
sdlsrc/video/windows/SDL_windowskeyboard.c:209: undefined reference to `ImmSetCompositionWindow@8'
sdlsrc/video/windows/SDL_windowskeyboard.c:210: undefined reference to `ImmReleaseContext@8'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_HandleMessage':
sdlsrc/video/windows/SDL_windowskeyboard.c:852: undefined reference to `ImmGetContext@4'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_GetCompositionString':
sdlsrc/video/windows/SDL_windowskeyboard.c:699: undefined reference to `ImmGetCompositionStringW@16'
sdlsrc/video/windows/SDL_windowskeyboard.c:704: undefined reference to `ImmGetCompositionStringW@16'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_HandleMessage':
sdlsrc/video/windows/SDL_windowskeyboard.c:890: undefined reference to `ImmReleaseContext@8'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_ClearComposition':
sdlsrc/video/windows/SDL_windowskeyboard.c:683: undefined reference to `ImmGetContext@4'
sdlsrc/video/windows/SDL_windowskeyboard.c:687: undefined reference to `ImmNotifyIME@16'
sdlsrc/video/windows/SDL_windowskeyboard.c:691: undefined reference to `ImmNotifyIME@16'
sdlsrc/video/windows/SDL_windowskeyboard.c:692: undefined reference to `ImmReleaseContext@8'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_HandleMessage':
sdlsrc/video/windows/SDL_windowskeyboard.c:885: undefined reference to `ImmGetContext@4'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_GetCandidateList':
sdlsrc/video/windows/SDL_windowskeyboard.c:767: undefined reference to `ImmGetCandidateListW@16'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_GetCompositionString':
sdlsrc/video/windows/SDL_windowskeyboard.c:699: undefined reference to `ImmGetCompositionStringW@16'
sdlsrc/video/windows/SDL_windowskeyboard.c:704: undefined reference to `ImmGetCompositionStringW@16'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_ClearComposition':
sdlsrc/video/windows/SDL_windowskeyboard.c:689: undefined reference to `ImmSetCompositionStringW@24'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_GetCandidateList':
sdlsrc/video/windows/SDL_windowskeyboard.c:771: undefined reference to `ImmGetCandidateListW@16'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_Render':
sdlsrc/video/windows/SDL_windowskeyboard.c:1520: undefined reference to `CreateCompatibleDC@4'
sdlsrc/video/windows/SDL_windowskeyboard.c:1525: undefined reference to `DeleteDC@4'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_RenderCandidateList':
sdlsrc/video/windows/SDL_windowskeyboard.c:1394: undefined reference to `CreatePen@12'
sdlsrc/video/windows/SDL_windowskeyboard.c:1395: undefined reference to `CreateSolidBrush@4'
sdlsrc/video/windows/SDL_windowskeyboard.c:1396: undefined reference to `CreatePen@12'
sdlsrc/video/windows/SDL_windowskeyboard.c:1397: undefined reference to `CreateSolidBrush@4'
sdlsrc/video/windows/SDL_windowskeyboard.c:1398: undefined reference to `CreatePen@12'
sdlsrc/video/windows/SDL_windowskeyboard.c:1399: undefined reference to `CreateSolidBrush@4'
sdlsrc/video/windows/SDL_windowskeyboard.c:1400: undefined reference to `CreateFontW@56'
sdlsrc/video/windows/SDL_windowskeyboard.c:1402: undefined reference to `SetBkMode@8'
sdlsrc/video/windows/SDL_windowskeyboard.c:1403: undefined reference to `SelectObject@8'
sdlsrc/video/windows/SDL_windowskeyboard.c:1410: undefined reference to `GetTextExtentPoint32W@16'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `StartDrawToBitmap':
sdlsrc/video/windows/SDL_windowskeyboard.c:1259: undefined reference to `CreateDIBSection@24'
sdlsrc/video/windows/SDL_windowskeyboard.c:1261: undefined reference to `SelectObject@8'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_RenderCandidateList':
sdlsrc/video/windows/SDL_windowskeyboard.c:1458: undefined reference to `SelectObject@8'
sdlsrc/video/windows/SDL_windowskeyboard.c:1459: undefined reference to `SelectObject@8'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `DrawRect':
sdlsrc/video/windows/SDL_windowskeyboard.c:1285: undefined reference to `Rectangle@20'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_RenderCandidateList':
sdlsrc/video/windows/SDL_windowskeyboard.c:1462: undefined reference to `SelectObject@8'
sdlsrc/video/windows/SDL_windowskeyboard.c:1463: undefined reference to `SelectObject@8'
sdlsrc/video/windows/SDL_windowskeyboard.c:1464: undefined reference to `SetTextColor@8'
sdlsrc/video/windows/SDL_windowskeyboard.c:1465: undefined reference to `SetBkMode@8'
sdlsrc/video/windows/SDL_windowskeyboard.c:1496: undefined reference to `SelectObject@8'
sdlsrc/video/windows/SDL_windowskeyboard.c:1497: undefined reference to `SelectObject@8'
sdlsrc/video/windows/SDL_windowskeyboard.c:1498: undefined reference to `SetTextColor@8'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `DrawRect':
sdlsrc/video/windows/SDL_windowskeyboard.c:1285: undefined reference to `Rectangle@20'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_RenderCandidateList':
sdlsrc/video/windows/SDL_windowskeyboard.c:1502: undefined reference to `ExtTextOutW@32'
sdlsrc/video/windows/SDL_windowskeyboard.c:1491: undefined reference to `SelectObject@8'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `StopDrawToBitmap':
sdlsrc/video/windows/SDL_windowskeyboard.c:1270: undefined reference to `DeleteObject@4'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj): In function `IME_RenderCandidateList':
sdlsrc/video/windows/SDL_windowskeyboard.c:1506: undefined reference to `DeleteObject@4'
sdlsrc/video/windows/SDL_windowskeyboard.c:1507: undefined reference to `DeleteObject@4'
sdlsrc/video/windows/SDL_windowskeyboard.c:1508: undefined reference to `DeleteObject@4'
sdlsrc/video/windows/SDL_windowskeyboard.c:1509: undefined reference to `DeleteObject@4'
projectdir\lib/libSDL2.a(SDL_windowskeyboard.c.obj):sdlsrc/video/windows/SDL_windowskeyboard.c:1510: more undefined references to `DeleteObject@4' follow
projectdir\lib/libSDL2.a(SDL_windowsmessagebox.c.obj): In function `WIN_ShowMessageBox':
sdlsrc/video/windows/SDL_windowsmessagebox.c:396: undefined reference to `CreateCompatibleDC@4'
sdlsrc/video/windows/SDL_windowsmessagebox.c:405: undefined reference to `CreateFontIndirectW@4'
sdlsrc/video/windows/SDL_windowsmessagebox.c:409: undefined reference to `SelectObject@8'
sdlsrc/video/windows/SDL_windowsmessagebox.c:413: undefined reference to `GetTextMetricsW@8'
sdlsrc/video/windows/SDL_windowsmessagebox.c:428: undefined reference to `DeleteDC@4'
projectdir\lib/libSDL2.a(SDL_windowsmessagebox.c.obj): In function `CreateDialogData':
sdlsrc/video/windows/SDL_windowsmessagebox.c:301: undefined reference to `GetDeviceCaps@8'
projectdir\lib/libSDL2.a(SDL_windowsmouse.c.obj): In function `WIN_CreateCursor':
sdlsrc/video/windows/SDL_windowsmouse.c:129: undefined reference to `CreateDIBSection@24'
sdlsrc/video/windows/SDL_windowsmouse.c:130: undefined reference to `CreateBitmap@20'
sdlsrc/video/windows/SDL_windowsmouse.c:140: undefined reference to `DeleteObject@4'
sdlsrc/video/windows/SDL_windowsmouse.c:141: undefined reference to `DeleteObject@4'
projectdir\lib/libSDL2.a(SDL_windowsshape.c.obj): In function `CombineRectRegions':
sdlsrc/video/windows/SDL_windowsshape.c:53: undefined reference to `CreateRectRgn@16'
sdlsrc/video/windows/SDL_windowsshape.c:55: undefined reference to `CombineRgn@16'
sdlsrc/video/windows/SDL_windowsshape.c:56: undefined reference to `DeleteObject@4'
projectdir\lib/libSDL2.a(SDL_windowswindow.c.obj): In function `WIN_SetWindowGammaRamp':
sdlsrc/video/windows/SDL_windowswindow.c:606: undefined reference to `CreateDCW@16'
sdlsrc/video/windows/SDL_windowswindow.c:608: undefined reference to `SetDeviceGammaRamp@8'
sdlsrc/video/windows/SDL_windowswindow.c:612: undefined reference to `DeleteDC@4'
projectdir\lib/libSDL2.a(SDL_windowswindow.c.obj): In function `WIN_GetWindowGammaRamp':
sdlsrc/video/windows/SDL_windowswindow.c:625: undefined reference to `CreateDCW@16'
sdlsrc/video/windows/SDL_windowswindow.c:627: undefined reference to `GetDeviceGammaRamp@8'
sdlsrc/video/windows/SDL_windowswindow.c:631: undefined reference to `DeleteDC@4'
projectdir\lib/libSDL2.a(SDL_systimer.c.obj): In function `SDL_SetSystemTimerResolution':
sdlsrc/timer/windows/SDL_systimer.c:57: undefined reference to `timeBeginPeriod@4'
sdlsrc/timer/windows/SDL_systimer.c:51: undefined reference to `timeEndPeriod@4'
projectdir\lib/libSDL2.a(SDL_systimer.c.obj): In function `SDL_TicksInit':
sdlsrc/timer/windows/SDL_systimer.c:102: undefined reference to `timeGetTime@0'
projectdir\lib/libSDL2.a(SDL_systimer.c.obj): In function `SDL_SetSystemTimerResolution':
sdlsrc/timer/windows/SDL_systimer.c:51: undefined reference to `timeEndPeriod@4'
projectdir\lib/libSDL2.a(SDL_systimer.c.obj): In function `SDL_GetTicks_REAL':
sdlsrc/timer/windows/SDL_systimer.c:141: undefined reference to `timeGetTime@0'
projectdir\lib/libSDL2.a(SDL_systimer.c.obj): In function `SDL_TicksInit':
sdlsrc/timer/windows/SDL_systimer.c:102: undefined reference to `timeGetTime@0'
projectdir\lib/libSDL2.a(SDL_systimer.c.obj): In function `SDL_GetTicks_REAL':
sdlsrc/timer/windows/SDL_systimer.c:141: undefined reference to `timeGetTime@0'
projectdir\lib/libSDL2.a(SDL_systimer.c.obj): In function `SDL_TicksInit':
sdlsrc/timer/windows/SDL_systimer.c:102: undefined reference to `timeGetTime@0'
projectdir\lib/libSDL2.a(SDL_mmjoystick.c.obj): In function `SDL_SYS_JoystickInit':
sdlsrc/joystick/windows/SDL_mmjoystick.c:166: undefined reference to `joyGetNumDevs@0'
sdlsrc/joystick/windows/SDL_mmjoystick.c:171: undefined reference to `joyGetPosEx@8'
sdlsrc/joystick/windows/SDL_mmjoystick.c:173: undefined reference to `joyGetDevCapsA@12'
projectdir\lib/libSDL2.a(SDL_mmjoystick.c.obj): In function `SDL_SYS_JoystickUpdate':
sdlsrc/joystick/windows/SDL_mmjoystick.c:326: undefined reference to `joyGetPosEx@8'
projectdir\lib/libSDL2.a(SDL_winmm.c.obj): In function `WINMM_CloseDevice':
sdlsrc/audio/winmm/SDL_winmm.c:170: undefined reference to `waveOutUnprepareHeader@12'
sdlsrc/audio/winmm/SDL_winmm.c:170: undefined reference to `waveOutUnprepareHeader@12'
sdlsrc/audio/winmm/SDL_winmm.c:182: undefined reference to `waveInClose@4'
sdlsrc/audio/winmm/SDL_winmm.c:187: undefined reference to `waveOutClose@4'
projectdir\lib/libSDL2.a(SDL_winmm.c.obj): In function `WINMM_PlayDevice':
sdlsrc/audio/winmm/SDL_winmm.c:131: undefined reference to `waveOutWrite@12'
projectdir\lib/libSDL2.a(SDL_winmm.c.obj): In function `SetMMerror':
sdlsrc/audio/winmm/SDL_winmm.c:106: undefined reference to `waveOutGetErrorTextW@12'
projectdir\lib/libSDL2.a(SDL_winmm.c.obj): In function `WINMM_OpenDevice':
sdlsrc/audio/winmm/SDL_winmm.c:285: undefined reference to `waveOutOpen@24'
sdlsrc/audio/winmm/SDL_winmm.c:331: undefined reference to `waveOutPrepareHeader@12'
projectdir\lib/libSDL2.a(SDL_winmm.c.obj): In function `PrepWaveFormat':
sdlsrc/audio/winmm/SDL_winmm.c:216: undefined reference to `waveOutOpen@24'
sdlsrc/audio/winmm/SDL_winmm.c:214: undefined reference to `waveInOpen@24'
projectdir\lib/libSDL2.a(SDL_winmm.c.obj): In function `WINMM_OpenDevice':
sdlsrc/audio/winmm/SDL_winmm.c:281: undefined reference to `waveInOpen@24'
projectdir\lib/libSDL2.a(SDL_winmm.c.obj): In function `DetectWaveInDevs':
sdlsrc/audio/winmm/SDL_winmm.c:57: undefined reference to `waveInGetNumDevs@0'
sdlsrc/audio/winmm/SDL_winmm.c:57: undefined reference to `waveInGetDevCapsW@12'
projectdir\lib/libSDL2.a(SDL_winmm.c.obj): In function `DetectWaveOutDevs':
sdlsrc/audio/winmm/SDL_winmm.c:56: undefined reference to `waveOutGetNumDevs@0'
sdlsrc/audio/winmm/SDL_winmm.c:56: undefined reference to `waveOutGetDevCapsW@12'
projectdir\lib/libSDL2.a(SDL_windowsframebuffer.c.obj): In function `WIN_CreateWindowFramebuffer':
sdlsrc/video/windows/SDL_windowsframebuffer.c:36: undefined reference to `DeleteDC@4'
sdlsrc/video/windows/SDL_windowsframebuffer.c:39: undefined reference to `DeleteObject@4'
sdlsrc/video/windows/SDL_windowsframebuffer.c:53: undefined reference to `CreateCompatibleBitmap@12'
sdlsrc/video/windows/SDL_windowsframebuffer.c:54: undefined reference to `GetDIBits@28'
sdlsrc/video/windows/SDL_windowsframebuffer.c:55: undefined reference to `GetDIBits@28'
sdlsrc/video/windows/SDL_windowsframebuffer.c:56: undefined reference to `DeleteObject@4'
sdlsrc/video/windows/SDL_windowsframebuffer.c:86: undefined reference to `CreateCompatibleDC@4'
sdlsrc/video/windows/SDL_windowsframebuffer.c:87: undefined reference to `CreateDIBSection@24'
sdlsrc/video/windows/SDL_windowsframebuffer.c:93: undefined reference to `SelectObject@8'
projectdir\lib/libSDL2.a(SDL_windowsframebuffer.c.obj): In function `WIN_UpdateWindowFramebuffer':
sdlsrc/video/windows/SDL_windowsframebuffer.c:102: undefined reference to `BitBlt@36'
projectdir\lib/libSDL2.a(SDL_windowsframebuffer.c.obj): In function `WIN_DestroyWindowFramebuffer':
sdlsrc/video/windows/SDL_windowsframebuffer.c:116: undefined reference to `DeleteDC@4'
sdlsrc/video/windows/SDL_windowsframebuffer.c:120: undefined reference to `DeleteObject@4'
projectdir\lib/libSDL2.a(SDL_windowsmodes.c.obj): In function `WIN_GetDisplayMode':
sdlsrc/video/windows/SDL_windowsmodes.c:108: undefined reference to `CreateDCW@16'
sdlsrc/video/windows/SDL_windowsmodes.c:112: undefined reference to `GetDeviceCaps@8'
sdlsrc/video/windows/SDL_windowsmodes.c:113: undefined reference to `GetDeviceCaps@8'
sdlsrc/video/windows/SDL_windowsmodes.c:153: undefined reference to `CreateCompatibleBitmap@12'
sdlsrc/video/windows/SDL_windowsmodes.c:154: undefined reference to `GetDIBits@28'
sdlsrc/video/windows/SDL_windowsmodes.c:155: undefined reference to `GetDIBits@28'
sdlsrc/video/windows/SDL_windowsmodes.c:156: undefined reference to `DeleteObject@4'
sdlsrc/video/windows/SDL_windowsmodes.c:157: undefined reference to `DeleteDC@4'
sdlsrc/video/windows/SDL_windowsmodes.c:137: undefined reference to `GetDeviceCaps@8'
sdlsrc/video/windows/SDL_windowsmodes.c:138: undefined reference to `GetDeviceCaps@8'
sdlsrc/video/windows/SDL_windowsmodes.c:145: undefined reference to `GetDeviceCaps@8'
sdlsrc/video/windows/SDL_windowsmodes.c:144: undefined reference to `GetDeviceCaps@8'
sdlsrc/video/windows/SDL_windowsmodes.c:108: undefined reference to `CreateDCW@16'
sdlsrc/video/windows/SDL_windowsmodes.c:112: undefined reference to `GetDeviceCaps@8'
sdlsrc/video/windows/SDL_windowsmodes.c:113: undefined reference to `GetDeviceCaps@8'
sdlsrc/video/windows/SDL_windowsmodes.c:153: undefined reference to `CreateCompatibleBitmap@12'
sdlsrc/video/windows/SDL_windowsmodes.c:154: undefined reference to `GetDIBits@28'
sdlsrc/video/windows/SDL_windowsmodes.c:155: undefined reference to `GetDIBits@28'
sdlsrc/video/windows/SDL_windowsmodes.c:156: undefined reference to `DeleteObject@4'
sdlsrc/video/windows/SDL_windowsmodes.c:157: undefined reference to `DeleteDC@4'
sdlsrc/video/windows/SDL_windowsmodes.c:137: undefined reference to `GetDeviceCaps@8'
sdlsrc/video/windows/SDL_windowsmodes.c:138: undefined reference to `GetDeviceCaps@8'
sdlsrc/video/windows/SDL_windowsmodes.c:145: undefined reference to `GetDeviceCaps@8'
sdlsrc/video/windows/SDL_windowsmodes.c:144: undefined reference to `GetDeviceCaps@8'
projectdir\lib/libSDL2.a(SDL_windowsopengl.c.obj): In function `WIN_GL_ChoosePixelFormatARB':
sdlsrc/video/windows/SDL_windowsopengl.c:446: undefined reference to `ChoosePixelFormat@8'
sdlsrc/video/windows/SDL_windowsopengl.c:446: undefined reference to `SetPixelFormat@12'
projectdir\lib/libSDL2.a(SDL_windowsopengl.c.obj): In function `WIN_GL_ChoosePixelFormat':
sdlsrc/video/windows/SDL_windowsopengl.c:208: undefined reference to `DescribePixelFormat@16'
sdlsrc/video/windows/SDL_windowsopengl.c:212: undefined reference to `DescribePixelFormat@16'
projectdir\lib/libSDL2.a(SDL_windowsopengl.c.obj): In function `WIN_GL_SetupWindowInternal':
sdlsrc/video/windows/SDL_windowsopengl.c:579: undefined reference to `SetPixelFormat@12'
projectdir\lib/libSDL2.a(SDL_windowsopengl.c.obj): In function `WIN_GL_InitExtensions':
sdlsrc/video/windows/SDL_windowsopengl.c:360: undefined reference to `ChoosePixelFormat@8'
sdlsrc/video/windows/SDL_windowsopengl.c:360: undefined reference to `SetPixelFormat@12'
projectdir\lib/libSDL2.a(SDL_windowsopengl.c.obj): In function `WIN_GL_SwapWindow':
sdlsrc/video/windows/SDL_windowsopengl.c:774: undefined reference to `SwapBuffers@4'
projectdir\lib/libSDL2.a(SDL_windowsopengl.c.obj): In function `WIN_GL_SetPixelFormatFrom':
sdlsrc/video/windows/SDL_windowsopengl.c:795: undefined reference to `GetPixelFormat@4'
sdlsrc/video/windows/SDL_windowsopengl.c:798: undefined reference to `DescribePixelFormat@16'
sdlsrc/video/windows/SDL_windowsopengl.c:801: undefined reference to `SetPixelFormat@12'
collect2.exe: error: ld returned 1 exit status

我怀疑也许我需要提供Windows库(我使用的是Windows 10)?如果是这种情况,我需要哪些库,哪里可以找到它们?当我使用预先构建的SDL2版本时,为什么不会出现此问题?

2 个答案:

答案 0 :(得分:0)

SDL2mainSDL2之前。链接订单很重要。

另外,对不起,我必须说这个

  

我从Code :: Blocks构建中获得了libSDL2和libSDL2main。我从Windows目录

获得了OpenGL32
听起来很奇怪。你不应该这样做。

我不确定“Code :: Blocks build”是什么意思,但你应该从http://libsdl.org/download-2.0.php获得SDL库以及其他地方。它被称为“MinGW build”

另一方面,OpenGL不应该在任何地方获得。它应该已经是您的编译器包的一部分。您可以将其与-lOpenGL32链接。

答案 1 :(得分:0)

如果您使用静态SDL进行链接,则需要手动提取它使用的所有库:

imagehlp dinput8 dxguid dxerr8 user32 gdi32 winmm imm32 ole32
oleaut32 shell32 version uuid

或者只使用动态SDL2。