微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

SDL2 Msys2 Windows X64 构建

如何解决SDL2 Msys2 Windows X64 构建

尝试使用最新的 MSYS 在 Windows 上构建 SDL2-2.0.14。

如果我尝试使用根 SDL 目录中的最小 makefile 进行构建,则会出现以下错误

cc -g -O2 -I./include   -c -o src/timer/dummy/SDL_systimer.o src/timer/dummy/SDL_systimer.c
cc -g -O2 -I./include   -c -o src/video/SDL_RLEaccel.o src/video/SDL_RLEaccel.c
cc -g -O2 -I./include   -c -o src/video/SDL_blit.o src/video/SDL_blit.c
cc -g -O2 -I./include   -c -o src/video/SDL_blit_0.o src/video/SDL_blit_0.c
cc -g -O2 -I./include   -c -o src/video/SDL_blit_1.o src/video/SDL_blit_1.c
cc -g -O2 -I./include   -c -o src/video/SDL_blit_A.o src/video/SDL_blit_A.c
cc -g -O2 -I./include   -c -o src/video/SDL_blit_N.o src/video/SDL_blit_N.c
cc -g -O2 -I./include   -c -o src/video/SDL_blit_auto.o src/video/SDL_blit_auto.c
cc -g -O2 -I./include   -c -o src/video/SDL_blit_copy.o src/video/SDL_blit_copy.c
cc -g -O2 -I./include   -c -o src/video/SDL_blit_slow.o src/video/SDL_blit_slow.c
cc -g -O2 -I./include   -c -o src/video/SDL_bmp.o src/video/SDL_bmp.c
cc -g -O2 -I./include   -c -o src/video/SDL_clipboard.o src/video/SDL_clipboard.c
cc -g -O2 -I./include   -c -o src/video/SDL_egl.o src/video/SDL_egl.c
src/video/SDL_egl.c:25:2: error: #error this should be not defined
   25 | #error this should be not defined
      |  ^~~~~
In file included from src/video/SDL_egl_c.h:28,from src/video/SDL_egl.c:36:
./include/SDL_egl.h:29:10: Fatal error: EGL/egl.h: No such file or directory
   29 | #include <EGL/egl.h>
      |          ^~~~~~~~~~~
compilation terminated.
make: *** [<builtin>: src/video/SDL_egl.o] Error 1

解决了在 include/SDL_config_windows.h:269 中删除 OPENGL 支持的问题:

#ifndef SDL_VIDEO_OPENGL_EGL
/* #define SDL_VIDEO_OPENGL_EGL    1  commented for wind64 build */
#endif

现在我有 libSDL.a 文件,但是如果我尝试从 test 文件夹构建一个测试:

Alessandro@DESKTOP-954PK5R MINGW64 /c/WORK/sdl_latest/SDL2-2.0.14/test
$ cc -g testkeys.c ../libSDL.a -I../include -o testkeys.exe
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\tmp\ccSosm3W.o: in function `SDL_main':
C:\WORK\sdl_latest\SDL2-2.0.14\test/testkeys.c:28: undefined reference to `SDL_LogSetPriority'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\WORK\sdl_latest\SDL2-2.0.14\test/testkeys.c:30: undefined reference to `SDL_Init'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\WORK\sdl_latest\SDL2-2.0.14\test/testkeys.c:31: undefined reference to `SDL_GetError'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\WORK\sdl_latest\SDL2-2.0.14\test/testkeys.c:31: undefined reference to `SDL_LogError'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\WORK\sdl_latest\SDL2-2.0.14\test/testkeys.c:35: undefined reference to `SDL_GetScancodeName'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\WORK\sdl_latest\SDL2-2.0.14\test/testkeys.c:35: undefined reference to `SDL_Log'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\WORK\sdl_latest\SDL2-2.0.14\test/testkeys.c:38: undefined reference to `SDL_Quit'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o): in function `main':
C:/_/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crt0_c.c:18: undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status

我需要链接其他东西吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。