I am trying to make a simple window with SDL2 in VSCode. I just can't seem to find a working solution anywhere. Every time I run my makefile or just run the command, I get the error"undefined reference to `WinMain@16'". I can't figure out why. My mingw is working fine as I can compile other files with no problem.
My program is this:
#include <iostream>
#include <SDL2/SDL.h>
const int WIDTH = 600;
const int HEIGHT = 600;
int main(int argc, char *argv[]){
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Window *window = SDL_CreateWindow("SDL TEST", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WIDTH, HEIGHT, 0);
if (window == NULL){
std::cout << "SDL WINDOW ERROR: " << SDL_GetError() << std::endl;
return 1;
}
SDL_Event windowEvent;
bool running = true;
while (running){
if (SDL_PollEvent(&windowEvent)){
if (windowEvent.type == SDL_QUIT){
running = false;
}
}
}
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}
My makefile is:
all:
g++ -I src/include -L src/lib -o main main.cpp -lmingw32 -lSDL2main -lSDL2
I have my main function and everything is compiled fine I think. Any help would be greatly appreciated!