Can't install SDL on MinGW, getting `undefined reference to WinMain@16`

人走茶凉 提交于 2020-01-30 03:01:28

问题


I'm trying to install SDL on MinGW.

I've downloaded SDL from here (the SDL2-devel-2.0.0-mingw.tar.gz link), then copied the contents of SDL2-2.0.0/x86_64-w64-mingw32/{bin,include,lib} into the matching directories in my MinGW installation.

When I try to compile any file that contains #include ‹SDL2/SDL.h› using gcc test.c -lmingw32 -lSDL2main -lSDL2 -mwindows, GCC complains about undefined reference to WinMain@16 and undefined reference to some SDL functions.


回答1:


SDL2-devel-2.0.0-mingw.tar.gz contains both 32-bit libraries (i686-w64-mingw32 directory) and 64-bit libraries (x86_64-w64-mingw32 directory).

The error was caused by using a 64-bit version of the library with a 32-bit compiler.



来源:https://stackoverflow.com/questions/18645392/cant-install-sdl-on-mingw-getting-undefined-reference-to-winmain16

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