13

过去几个月我一直在使用 sdl 1.2(在 Windows 上)。我正在考虑迁移到 1.3。所以我使用 cmake 和代码块来创建静态和动态库。现在我很困惑如何编译程序。我包含了 sdl.h 头文件。在链接器中添加了静态库。但是当我尝试编译很多未定义的错误不断发生:

D:\using font\sdl_2test\main.c||In function 'SDL_main':|
D:\using font\sdl_2test\main.c|9|warning: passing argument 6 of 'SDL_CreateWindow' makes integer from pointer without a cast|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\include\SDL_video.h|405|note: expected 'Uint32' but argument is of type 'void *'|
D:\using font\sdl_2test\main.c|11|warning: control reaches end of non-void function|
..\..\GameDev\SDL_2\static\libSDL2.a(SDL_windowsmodes.c.obj)||In function `WIN_GetDisplayMode':|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsmodes.c|62|undefined reference to `CreateDCW@16'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsmodes.c|71|undefined reference to `CreateCompatibleBitmap@12'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsmodes.c|72|undefined reference to `GetDIBits@28'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsmodes.c|73|undefined reference to `GetDIBits@28'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsmodes.c|74|undefined reference to `DeleteObject@4'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsmodes.c|75|undefined reference to `DeleteDC@4'|
..\..\GameDev\SDL_2\static\libSDL2.a(SDL_windowswindow.c.obj)||In function `WIN_GetWindowGammaRamp':|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowswindow.c|530|undefined reference to `CreateDCW@16'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowswindow.c|532|undefined reference to `GetDeviceGammaRamp@8'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowswindow.c|536|undefined reference to `DeleteDC@4'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowswindow.c|536|undefined reference to `DeleteDC@4'|
..\..\GameDev\SDL_2\static\libSDL2.a(SDL_windowswindow.c.obj)||In function `WIN_SetWindowGammaRamp':|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowswindow.c|511|undefined reference to `CreateDCW@16'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowswindow.c|513|undefined reference to `SetDeviceGammaRamp@8'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowswindow.c|517|undefined reference to `DeleteDC@4'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowswindow.c|517|undefined reference to `DeleteDC@4'|
..\..\GameDev\SDL_2\static\libSDL2.a(SDL_windowsframebuffer.c.obj)||In function `WIN_DestroyWindowFramebuffer':|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsframebuffer.c|114|undefined reference to `DeleteDC@4'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsframebuffer.c|118|undefined reference to `DeleteObject@4'|
..\..\GameDev\SDL_2\static\libSDL2.a(SDL_windowsframebuffer.c.obj)||In function `WIN_UpdateWindowFramebuffer':|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsframebuffer.c|100|undefined reference to `BitBlt@36'|
..\..\GameDev\SDL_2\static\libSDL2.a(SDL_windowsframebuffer.c.obj)||In function `WIN_CreateWindowFramebuffer':|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsframebuffer.c|36|undefined reference to `DeleteDC@4'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsframebuffer.c|39|undefined reference to `DeleteObject@4'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsframebuffer.c|50|undefined reference to `CreateCompatibleBitmap@12'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsframebuffer.c|51|undefined reference to `GetDIBits@28'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsframebuffer.c|52|undefined reference to `GetDIBits@28'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsframebuffer.c|53|undefined reference to `DeleteObject@4'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsframebuffer.c|83|undefined reference to `CreateCompatibleDC@4'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsframebuffer.c|84|undefined reference to `CreateDIBSection@24'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsframebuffer.c|91|undefined reference to `SelectObject@8'|
..\..\GameDev\SDL_2\static\libSDL2.a(SDL_windowsshape.c.obj)||In function `CombineRectRegions':|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsshape.c|53|undefined reference to `CreateRectRgn@16'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsshape.c|55|undefined reference to `CombineRgn@16'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsshape.c|56|undefined reference to `DeleteObject@4'|
..\..\GameDev\SDL_2\static\libSDL2.a(SDL_windowsopengl.c.obj)||In function `WIN_GL_SwapWindow':|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsopengl.c|668|undefined reference to `SwapBuffers@4'|
..\..\GameDev\SDL_2\static\libSDL2.a(SDL_windowsopengl.c.obj)||In function `WIN_GL_ChoosePixelFormatARB':|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsopengl.c|399|undefined reference to `ChoosePixelFormat@8'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsopengl.c|399|undefined reference to `SetPixelFormat@12'|
..\..\GameDev\SDL_2\static\libSDL2.a(SDL_windowsopengl.c.obj)||In function `WIN_GL_SetupWindow':|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsopengl.c|518|undefined reference to `SetPixelFormat@12'|
..\..\GameDev\SDL_2\static\libSDL2.a(SDL_windowsopengl.c.obj)||In function `WIN_GL_ChoosePixelFormat':|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsopengl.c|206|undefined reference to `DescribePixelFormat@16'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowsopengl.c|210|undefined reference to `DescribePixelFormat@16'|
..\..\GameDev\SDL_2\static\libSDL2.a(SDL_windowskeyboard.c.obj)||In function `IPPASink_QueryInterface@12':|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowskeyboard.c|1117|undefined reference to `IID_IUnknown'|
..\..\GameDev\SDL_2\static\libSDL2.a(SDL_windowskeyboard.c.obj)||In function `UIElementSink_QueryInterface@12':|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowskeyboard.c|1011|undefined reference to `IID_IUnknown'|
..\..\GameDev\SDL_2\static\libSDL2.a(SDL_windowskeyboard.c.obj)||In function `IME_SetupAPI':|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowskeyboard.c|613|undefined reference to `ImmGetIMEFileNameA@12'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowskeyboard.c|626|undefined reference to `ImmGetContext@4'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowskeyboard.c|629|undefined reference to `ImmReleaseContext@8'|
..\..\GameDev\SDL_2\static\libSDL2.a(SDL_windowskeyboard.c.obj)||In function `IME_ClearComposition':|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowskeyboard.c|679|undefined reference to `ImmGetContext@4'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowskeyboard.c|683|undefined reference to `ImmNotifyIME@16'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowskeyboard.c|687|undefined reference to `ImmNotifyIME@16'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowskeyboard.c|688|undefined reference to `ImmReleaseContext@8'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowskeyboard.c|685|undefined reference to `ImmSetCompositionStringW@24'|
..\..\GameDev\SDL_2\static\libSDL2.a(SDL_windowskeyboard.c.obj)||In function `IME_GetCompositionString':|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowskeyboard.c|695|undefined reference to `ImmGetCompositionStringW@16'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowskeyboard.c|700|undefined reference to `ImmGetCompositionStringW@16'|
..\..\GameDev\SDL_2\static\libSDL2.a(SDL_windowskeyboard.c.obj)||In function `IME_GetId':|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowskeyboard.c|547|undefined reference to `ImmGetIMEFileNameA@12'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowskeyboard.c|562|undefined reference to `GetFileVersionInfoSizeA@8'|
D:\GameDev\SDL-2.0\SDL-2.0.0-6799\src\video\windows\SDL_windowskeyboard.c|566|undefined reference to `GetFileVersionInfoA@16'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 2 warnings ===|

我错过了什么?:/

4

1 回答 1

22

我也在寻找这个问题的答案,因为我找不到,这对我有用:

如果使用 mingw 作为编译器,则必须按此顺序链接到以下库:

-lmingw32 -lSDL2main -lSDL2 -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid 
于 2013-08-10T13:59:44.323 回答