0
#include "sdl.h"
#include <stdio.h>
#include <stdlib.h>

SDL_Surface* g_pMainSurface = NULL;
SDL_Event g_Event;

int main(int argc, char* argv[])
{
    if (SDL_Init(SDL_INIT_VIDEO)==-1)
    {
        fprintf(stderr, "Could not initialize SDL!\n");
        exit(1);
    }

    else
    {
        fprintf(stdout, "SDL initialized properly!\n");
        atexit(SDL_Quit);
    }

    g_pMainSurface = SDL_SetVideoMode(640, 480, 0, SDL_ANYFORMAT);

    if (!g_pMainSurface)
    {
        fprintf(stderr, "Could not creat main surface!\n");
        exit(1);
    }

    for (;;)
    {
        if (SDL_WaitEvent(&g_Event) == 0)
        {
            exit(1);
        }

        if (g_Event.type == SDL_QUIT)
        {
            fprintf(stdout, "Quit event has occurred.\n");
            break;
        }

    }

    fprintf(stdout, "Terminating program normally.\n");
    return (0);
}

1>main.obj : error LNK2019: unresolved external symbol _SDL_SetVideoMode referenced in function _SDL_main

1>main.obj : error LNK2019: unresolved external symbol _SDL_WaitEvent referenced in function _SDL_main

1>main.obj : error LNK2019: unresolved external symbol _SDL_Init referenced in function _SDL_main

1>main.obj : error LNK2019: unresolved external symbol _SDL_Quit referenced in function _SDL_main

1>MSVCRT.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function "int __cdecl __scrt_common_main_seh(void)" (?__scrt_common_main_seh@@YAHXZ)

genpfault
  • 51,148
  • 11
  • 85
  • 139

2 Answers2

1

Your project is likely missing the SDL static library references. Open your project properties window, go to the Linker Settings, and add the paths to your SDL static library files.

Dai
  • 141,631
  • 28
  • 261
  • 374
1

You should learn sdl 2.0 , sdl 1 is out of age ! btw try to add :

pragma comment(lib,"SDL.lib")

pragma comment(lib,"SDLmain.lib")

Community
  • 1
  • 1