I have been trying to get SDL2 to work in my environment but have had no luck. I am using Windows 10 Home with MinGW, working in Eclipse IDE for C/C++ Developers.
I downloaded SDL2.26.4 from this GitHub repository.
After downloading and extracting the files, I copied the contents of the SDL2 include and lib files to my MinGW folder in C:\MinGW.
In my IDE, I added the include and library paths.
I also included some recommended linker flags suggested from other solutions, but they have had no impact.
When I run the following code:
#include <iostream>
#define SDL_MAIN_HANDLED
#include <SDL.h>
using namespace std;
int main() {
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;
}
...I am met with errors:
C:\Users\User\eclipse-workspace\SDL2 test\Debug/../src/SDL2 test.cpp:12: multiple definition of `main'
C:\MinGW\lib/libmingw32.a(main.o):(.text.startup+0x0): first defined here
C:\MinGW\lib/libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
I've tried recreating my project, putting my include and library folders in different file locations, different variations of inhibiting SDL from redefining my 'main' function, but nothing has worked.