使用mingw编译SDL2会在函数“SDL_main”中出现错误:

时间:2015-05-17 11:02:38

标签: c++ sdl-2 mingw32

我尝试使用mingw(最新版本)和SDL2-devel-2.0.2-mingw来编写简单SDL2的lazyfoo教程。 我使用这个编译命令:

G:\dev\cpp\SDL\tests_mingw\01_hello_SDL\01_hello_SDL>g++ -g 01_hello_SDL.cpp -IC:\Dev64\mingw_libs\include\SDL2 -LC:\Dev64\mingw_libs\lib -w -Wl,-subsystem,windows -lmingw32 -lSDL2main -LSDL2 -o
01_hello_SDL.exe 

我收到这些链接器错误:

C:\Users\Y~1.DM-\AppData\Local\Temp\ccELvhvQ.o: In function `SDL_main':
G:\dev\cpp\SDL\tests_mingw\01_hello_SDL\01_hello_SDL/01_hello_SDL.cpp:21: undefined reference to `SDL_Init'
G:\dev\cpp\SDL\tests_mingw\01_hello_SDL\01_hello_SDL/01_hello_SDL.cpp:23: undefined reference to `SDL_GetError'
G:\dev\cpp\SDL\tests_mingw\01_hello_SDL\01_hello_SDL/01_hello_SDL.cpp:28: undefined reference to `SDL_CreateWindow'
G:\dev\cpp\SDL\tests_mingw\01_hello_SDL\01_hello_SDL/01_hello_SDL.cpp:31: undefined reference to `SDL_GetError'
G:\dev\cpp\SDL\tests_mingw\01_hello_SDL\01_hello_SDL/01_hello_SDL.cpp:36: undefined reference to `SDL_GetWindowSurface'
G:\dev\cpp\SDL\tests_mingw\01_hello_SDL\01_hello_SDL/01_hello_SDL.cpp:39: undefined reference to `SDL_MapRGB'
G:\dev\cpp\SDL\tests_mingw\01_hello_SDL\01_hello_SDL/01_hello_SDL.cpp:39: undefined reference to `SDL_FillRect'
G:\dev\cpp\SDL\tests_mingw\01_hello_SDL\01_hello_SDL/01_hello_SDL.cpp:42: undefined reference to `SDL_UpdateWindowSurface'
G:\dev\cpp\SDL\tests_mingw\01_hello_SDL\01_hello_SDL/01_hello_SDL.cpp:45: undefined reference to `SDL_Delay'
G:\dev\cpp\SDL\tests_mingw\01_hello_SDL\01_hello_SDL/01_hello_SDL.cpp:50: undefined reference to `SDL_DestroyWindow'
G:\dev\cpp\SDL\tests_mingw\01_hello_SDL\01_hello_SDL/01_hello_SDL.cpp:53: undefined reference to `SDL_Quit'
C:\Dev64\mingw_libs\lib/libSDL2main.a(SDL_windows_main.o): In function `console_main':
/Users/slouken/release/SDL/SDL2-2.0.2-source/foo-x86/../src/main/windows/SDL_windows_main.c:137: undefined reference to `SDL_SetMainReady'
C:\Dev64\mingw_libs\lib/libSDL2main.a(SDL_windows_main.o): In function `WinMain@16':
/Users/slouken/release/SDL/SDL2-2.0.2-source/foo-x86/../src/main/windows/SDL_windows_main.c:160: undefined reference to `SDL_wcslen'
/Users/slouken/release/SDL/SDL2-2.0.2-source/foo-x86/../src/main/windows/SDL_windows_main.c:160: undefined reference to `SDL_iconv_string'
C:\Dev64\mingw_libs\lib/libSDL2main.a(SDL_windows_main.o): In function `ParseCommandLine':
/Users/slouken/release/SDL/SDL2-2.0.2-source/foo-x86/../src/main/windows/SDL_windows_main.c:57: undefined reference to `SDL_isspace'
C:\Dev64\mingw_libs\lib/libSDL2main.a(SDL_windows_main.o): In function `WinMain@16':
/Users/slouken/release/SDL/SDL2-2.0.2-source/foo-x86/../src/main/windows/SDL_windows_main.c:170: undefined reference to `SDL_malloc'
C:\Dev64\mingw_libs\lib/libSDL2main.a(SDL_windows_main.o): In function `ParseCommandLine':
/Users/slouken/release/SDL/SDL2-2.0.2-source/foo-x86/../src/main/windows/SDL_windows_main.c:83: undefined reference to `SDL_isspace'
/Users/slouken/release/SDL/SDL2-2.0.2-source/foo-x86/../src/main/windows/SDL_windows_main.c:57: undefined reference to `SDL_isspace'
/Users/slouken/release/SDL/SDL2-2.0.2-source/foo-x86/../src/main/windows/SDL_windows_main.c:83: undefined reference to `SDL_isspace'
collect2.exe: error: ld returned 1 exit status

我在这里做错了什么?
我正在使用32位编译。

0 个答案:

没有答案