0

I am trying to render an image into a window I created using SDL. When I go to run it I get the following error.

Error 3 error LNK2019: unresolved external symbol "bool __cdecl loadMedia(void)" (?loadMedia@@YA_NXZ) referenced in function _SDL_main

#include "stdafx.h"

using namespace std;
//const char *titles[] = { "SDL Game" };

bool quit = false;


int main(int argc, char* argv[])

{
    SDL_Init(SDL_INIT_VIDEO);
    SDL_Window* window = NULL;

    window = SDL_CreateWindow("SDL Game", 150, 150, 800, 600, SDL_WINDOW_RESIZABLE); // Create         window with parameters

    // if statement if window cant be created 
    if (window == NULL);
    {
        cout << "Instance window could not be created" << endl
            << SDL_GetError() << endl;
    }

//The surface contained by the window
SDL_Surface* gScreenSurface = NULL;

//The image we will load and show on the screen
SDL_Surface* img_background = NULL;

bool loadMedia();
{
    //Loading success flag
    bool success = true;

    //Load splash image
    img_background = SDL_LoadBMP("abstract-green-background-1361187771Euk.bmp");
    if (img_background == NULL)

        // unable to load image error
        printf("Unable to load image %s! SDL Error: %s\n", "abstract-green-background-1361187771Euk.bmp", SDL_GetError());
    success = false;
}


// If function to apply the image and update the surface
if (!loadMedia())
{
    printf("Failed to load media!\n");
}
else
{
    //Apply the image
    SDL_BlitSurface(img_background, NULL, gScreenSurface, NULL);

    //Update the surface
    SDL_UpdateWindowSurface(window);

// Quit SDL
    SDL_DestroyWindow(window);
    SDL_Quit();
    return 0;
}
    }

Please not that #include "stdafx.h" at the moment is only including SDL.h and iostream

Can anyone please advise why this is happening?

Thanks

PapaSmurf
  • 161
  • 4
  • 15
  • One unrelated problem is `if (window == NULL);` - the semicolon should not be there. – Captain Obvlious Sep 20 '14 at 16:12
  • @CaptainObvlious Why is the semicolon not needed? Thanks – PapaSmurf Sep 20 '14 at 16:28
  • Because it terminates the `if` statement and causes the compound statement following it to always be executed. I suggest you get a [good book](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) on C++. – Captain Obvlious Sep 20 '14 at 16:46

0 Answers0