1

My version of DEV C++ is 5.11 and I have used version SDL2-2.0.12 and OS is Windows 10. Folder path of sdl.h file is C:\Program Files (x86)\Dev-Cpp\SDL2-2.0.12\x86_64-w64-mingw32\include\SDL2

I have done my project settings as shown in :: https://thenumbat.github.io/cpp-course/sdl2/01/devSetup.html#:~:text=Open%20up%20your%20project%20and,and%20select%20the%20lib%20folder.

My program

#include <iostream>
#include "SDL.h"

using namespace std;

int main( int argc, char* args[] )
{
  
        if(SDL_Init(SDL_INIT_EVERYTHING) < 0) 
        {
            cout << "SDL init failed.\n";
            return 1;
        }       
        
        SDL_Quit();    
        return 0;    
}

While compiling I am getting such message::

C:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib\libmingw32.a(lib64_libmingw32_a-crt0_c.o) In function `main':

C:\crossdev\src\mingw-w64-v3-git\mingw-w64-crt\crt\crt0_c.c undefined reference to `WinMain'

------ this is in red color ---------
C:\Program Files (x86)\Dev-Cpp\SDL2-2.0.12\x86_64-w64-mingw32\collect2.exe  [Error] ld returned 1 exit status

C:\Program Files (x86)\Dev-Cpp\SDL2-2.0.12\x86_64-w64-mingw32\Makefile.win  recipe for target 'SDLproj1.exe' failed

Please see the attached image.

enter image description here

Botje
  • 26,269
  • 3
  • 31
  • 41
nischalinn
  • 1,133
  • 2
  • 12
  • 38
  • 1
    this answer https://stackoverflow.com/questions/5259714/undefined-reference-to-winmain16/5260237#5260237 – n. m. could be an AI Oct 09 '20 at 11:45
  • 1
    Can you provide the contents of the `Compile Log` tab? – HolyBlackCat Oct 09 '20 at 20:04
  • @n.'pronouns'm. OP uses MinGW, so it doesn't seem to apply. The problem is related to SDL2's `#define main ...`, but I'm not sure what exactly is going on here. – HolyBlackCat Oct 10 '20 at 11:33
  • 1
    @HolyBlackCat SDL does `#define main` but the undefined symbol is WinMain. The comments is SDL_main.h say "Windows SDL provides WinMain()" so one needs to link to SDL2main.lib that provides it, see https://wiki.libsdl.org/FAQWindows – n. m. could be an AI Oct 10 '20 at 11:51

0 Answers0