Unable to link to SDL2 functions using MinGW

爱⌒轻易说出口 提交于 2019-11-30 17:44:49

A possible problem is that your linking to a SDL2 library for a different architecture.

You should be using

SDL2-2.0.1\i686-w64-mingw32

instead of

SDL2-2.0.1\x86_64-w64-mingw32

Also after setting the library search path use this notation to link to libraries

-lmingw32 -lSDL2main -lSDL2

It's much easier to read.

ollo

Instead of adding full path, try -LC:/PATH_TO_SDL -lSDL2main -lSDL2 (or only one SDL option) instead; the lib and .a is already known by the linker.

(not sure if you have to use either / or \)

Since you are using C++, replace your include with this:

extern "C"
{
    #include "SDL.h"
}

This tells the compiler to treat SDL as C - and not C++ - code.

See also: SDL2 won't link properly

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