#include <SDL.h>
#include <iostream.h>
int main(int argc, char* argv[])
{
//initialize SDL and the video system.
if (SDL_Init( SDL_INIT_VIDEO)<0)
return -1;
//signal SDL to change the text of the main window to SDL "Hello World".
SDL_WM_SetCaption("Hello world","Hello World");
//Create an SDL_Surface object, which represents, the game window.
SDL_Surface* screen=SDL_SetVideoMode(640,480,0,0);
//Load the SDL logo bitmap to a temporary surface
SDL_Surface* temp=SDL_LoadBMP("data\\structures\\sdl_logo.bmp");
//Create the working SDL surface which matches the display format of the temporary surface.
SDL_Surface* bg= SDL_DisplayFormat(temp);
//Free the memory allocated to the temporary SDL_Surface.
SDL_FreeSurface(temp);
SDL_Event event;
bool quit=false;
//this is the main message loop if the game.
while(!quit)
{
//Check message qeue for an event.
if (SDL_PollEvent(&event))
{
//If an event was found.
switch (event.type)
{
//check to see if the window was closed via the "x"
case SDL_QUIT:
//Set the quit flag to true
quit=true;
break;
//Check the keyboard to see if the ESC key was pressed.
case SDL_KEYDOWN:
switch (event.key.keysym.sym)
{
case SDLK_ESCAPE:
//set our quit flag to true
quit=true;
break;
}
break;
}
}
//Draw the background sprite:
SDL_BlitSurface(bg, NULL, screen, NULL);
//Update the current window.
SDL_UpdateRect(screen,0,0,0,0);
}
//Free the allocated memery for the background surface.
SDL_FreeSurface(bg);
//Quit SDL and allow it to clean up everything.
SDL_Quit();
//return control to windows with no errors.
return 0;
}
But in the end my compiler comes with a lot of errors, all of them is:
[Linker error] undefined reference to `Something'
basically any command in the source code (Any SDL commands that is).
I have read in other threads, that it's because i have forgotten to include the library, but i think i have.
I'm using the dev-c++ compiler.
I went into the: Tools fan, and then chose: compiler options.
Then i chose Directories.
After that i went to the: "Directories" fan.
In here, there are three deifferend things i can include:
Binaries, Libraries, C includes and C++ includes.
I didn't include anything in binaries, since i couldn't find any SDL binaries.
I included the directory called: "Lib", as the SDL library.
I included the directory called: "Include" as both the C includes and the C++ includes, since i didn't know which of them it was supposed to be included as.
SDL, needs to be installed, and as so, it get's a stand alone directory, in C:/Program files/SDL (Or whereever you choose to locate it), the directorires i refer to, that i included, are all directories located in that directory.
So it seems, to me, like i included about everything, that's supposed to be included.
It should be said that i'm learning C++. so i'm a n00b at this. I'm new to both the langauge and the compiler, though i have programmed in another langauge, for pretty some while.
But since i'm new, i would ask you to now assume that i can anything, cause i realy can't. So please help me, step by step, i haven't even made the source code. It's from my stipendium.
O, and please tell me why i have to do what i have to do. I don't just wanna know how to fix it, i also wanna know why i'm fixing it the way i am, since i'm learning the langauge, i would also like to learn from this mistake ^^
i would also like to know how to correct the error, from the title. ([Linker error] undefined reference to `WinMain@16') i have came to the understanding, that, that specific error has another way to be corrected, than the rest.