1
votes

So I'm trying to compile this.

#include "SDL.h"

int main(int argc, char* args[])
{
    //Start SDL
    SDL_Init(SDL_INIT_EVERYTHING);

    //Quit SDL
    SDL_Quit();

    return 0;
}

Shows me these errors:

Error 2 error LNK2019: unresolved external symbol _SDL_Quit referenced in function _SDL_main C:\Users\Scrub\Desktop\C++\SDL__tutorial\main.obj

Error 1 error LNK2019: unresolved external symbol _SDL_Init referenced in function _SDL_main C:\Users\Scrub\Desktop\C++\SDL__tutorial\main.obj

Error 3 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup C:\Users\Scrub\Desktop\C++\SDL__tutorial\MSVCRT.lib(crtexe.obj)

Error 4 error LNK1120: 3 unresolved externals C:\Users\Scrub\Desktop\C++\SDL__tutorial\Debug\SDL__tutorial.exe 1

I've tried searching these errors everywhere; tried all the supposed fixes, it still does this.

Edit - I've somewhat fixed this(By switching to x86 lib and #undef main), but now when i build and launch it, it shows an application error

The application was unable to start correctly (0xc0000007b)

Still produces almost the same errors with windows subsystem

Error 3 error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup C:\Users\Scrub\Desktop\C++\SDL__tutorial\MSVCRT.lib(crtexew.obj)

Error 2 error LNK2019: unresolved external symbol _SDL_Quit referenced in function _SDL_main C:\Users\Scrub\Desktop\C++\SDL__tutorial\main.obj

Error 1 error LNK2019: unresolved external symbol _SDL_Init referenced in function _SDL_main C:\Users\Scrub\Desktop\C++\SDL__tutorial\main.obj

Error 4 error LNK1120: 3 unresolved externals C:\Users\Scrub\Desktop\C++\SDL__tutorial\Debug\SDL__tutorial.exe

1

1 Answers

1
votes

Are you using Visual Studio? It seems like your linker can't find your main function. Right click on your project, go to Properties -> Configuration Properties -> Linker -> System and try changing the Subsystem to either Console or Windows, whichever one works (source). I don't know which supposed fixes you've tried, so hopefully this one solves your issue.

I'm new to Stackoverflow so I hope I did this right and that this helps!