At first, here's my source code:

#include <SDL.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;
}

Well... my problem is, that i in some way must have mis-configured, my compiler. But since i'm new (Both at programming c++ and at using the compiler), i don't know how :S
the error meesages are, the following:
[Linker error] undefined reference to `SDL_Init'
[Linker error] undefined reference to `SDL_WM_SetCaption'
[Linker error] undefined reference to `SDL_SetVideoMode'
[Linker error] undefined reference to `SDL_RWFromFile'
[Linker error] undefined reference to `SDL_LoadBMP_RW'
[Linker error] undefined reference to `SDL_DisplayFormat'
[Linker error] undefined reference to `SDL_FreeSurface'
[Linker error] undefined reference to `SDL_PollEvent'
[Linker error] undefined reference to `SDL_UpperBlit'
[Linker error] undefined reference to `SDL_UpdateRect'
[Linker error] undefined reference to `SDL_FreeSurface'
[Linker error] undefined reference to `SDL_Quit'
[Linker error] undefined reference to `WinMain@16'
ld returned 1 exit status
As you can see, any command that i have used, which starts with SDL, has an undefinded referance. As i have come to understand, it has something to do with the way i have inclueded my files.
If some-one out there have used the dev-c++ compiler (Which i'm using), and also have experiaence with connecting that compiler to the SDL, it would be REALY nice if you would give me a, step, by step, tutorial, in how to do it. But it would also be nice if any1 else would bother to anwser, because that might be enouth to help me.
Please take in notice, that i'm VERY new to the langauge and compiler, so please don't use any words/sentences, that only experienced users understand

I think the question here is, if anyone can be bothered to download SDL to test it.

Personally, I don't think anyone is going to do that. Btw I have dev-cpp :)

Well... ty both, that seemewd to help, but now i'm getting some strange new errors :S Which i don't understand...

multiple definition of `main'
first defined here
.drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized
[Linker error] undefined reference to `_alloca_probe'
[Linker error] undefined reference to `_alloca_probe'
[Linker error] undefined reference to `_alloca_probe' (Yeah, this error comes three times)
ld returned 1 exit status
C:\Dev-Cpp\Projekt hej\Makefile.win [Build Error] [HEJ.exe] Error 1

The two last errors should correct themselves, if the others are corrected (At least thats what i have come to understand).
But i don't understand that it says i have two main functions, cause i don't
and neither do i understand the '_alloca_probe', i haven't even used it in my source code:

#include <SDL.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;
}

Okay... this is strange, the same errors comes, even if i break the source code down to:

#include <SDL.h>

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

}

add -lmingw32 -lSDLmain -lSDL to the Linker parameter in additional command-line options

(project menu, project options, parameters tab)

add -lmingw32 -lSDLmain -lSDL to the Linker parameter in additional command-line options

(project menu, project options, parameters tab)

Nothing like being 2 years late :(

Nothing like being 2 years late :(

I realized before I posted that it was old.

It's also the first search result in google when searching for the error.

Thx. Its is 6 years ago, bud thx.

Makefile

CXX                     = g++
CXXFLAGS                = -c -Wall -I/usr/local/include/SDL2/ 


# -L/usr/local/libs/SDL2/libSDL2main.a
# libSDLmain.a (SDLmain.lib) and libSDL.a (SDL.lib)
#libSDLmain.a SDLmain.lib 
#libSDL.a SDL.lib
# -------------------------------------------------------------------------------


all: prog

prog: main.o 
    $(CXX) main.o -lSDLmain -lSDL -o Prog

main.o: main.cpp
    $(CXX) $(CXXFLAGS) main.cpp

clean:
    rm -rf ./*.o Prog
# -------------------------------------------------------------------------------
This article has been dead for over six months. Start a new discussion instead.