Linker Errors from SDL2 in my project

匿名 (未验证) 提交于 2019-12-03 02:38:01

问题:

I used CMake and Code::Blocks to build SDL2 from source, and attempted to link my own project source to the following static libraries:

libSDL2.a libSDL2main.a OpenGL32.lib 

These three libraries are contained within the directory known as %libdir% (I'm using Batch for the command).

I obtained libSDL2 and libSDL2main from the Code::Blocks build. I obtained OpenGL32 from my Windows directory, although I found it long ago so I am unable to recall the exact location. I used the following command:

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

Below is the log, how can I rectify these errors?:

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 

I suspected that perhaps I need to provide windows libraries (I'm using windows 10)? If that is the case, which libraries do I need and where can I find them? Why did this issue not occur when I used a pre-built version of SDL2?

回答1:

If you link with static SDL, you need to manually pull all libraries it uses:

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

Or just use dynamic SDL2.



回答2:

SDL2main goes before SDL2. Linking order matters.


Also, I'm sorry, but I must say that this

I obtained libSDL2 and libSDL2main from the Code::Blocks build. I obtained OpenGL32 from my Windows directory

sounds weird. You shouldn't do it like this.

I'm not sure what you mean by "Code::Blocks build", but you should obtain SDL libs as well as includes for it from http://libsdl.org/download-2.0.php and nowhere else. It's called "MinGW build".

OpenGL, on the other hand, shouldn't be obtained anywhere. It should already be a part of your compiler package. You can link it with just -lOpenGL32.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!