Problems with SDL (LNK1561)

This is a discussion on Problems with SDL (LNK1561) within the C++ Programming forums, part of the General Programming Boards category; Hi everyone! I've been reading SDLtutorials.com and now I'm learning the "Per pixel Collision" tutorial but whenever I try to ...

  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    2

    Question Problems with SDL (LNK1561)

    Hi everyone!

    I've been reading SDLtutorials.com and now I'm learning the "Per pixel Collision" tutorial but whenever I try to Build my programs it comes out with a LNK5161 error..
    Here is the code:

    game.h
    Code:
    #ifndef GAME_H
    #define GAME_H
    #include "SDL.h"
    
    class game
    {
    public:
        game();
        ~game();
    
        void onexecute();
    
        void onthink();
        void onupdate();
        void onrender();
    
    private:
        int screenwidth;
        int screenheight;
        int screenbbp;
        Uint32 screenflags;
    
        bool done;
    
        double thistime;
        double lasttime;
        double deltatime;
    
        SDL_Surface* screen;
        SDL_Event event;
    };
    
    #endif
    Game.cpp
    Code:
    #include "Games.h"
    
    game::game()
    {
        screenwidth=800;
        screenheight=600;
        screenbbp=32;
        screenflags=SDL_HWSURFACE | SDL_DOUBLEBUF;
    
        thistime=0.0;
        lasttime=0.0;
        deltatime=0.0;
    
        done=false;
    
        SDL_Init(SDL_INIT_EVERYTHING);
        SDL_WM_SetCaption("SDL Per Pizel Collision", NULL);
        SDL_ShowCursor(0);
    
        screen=SDL_SetVideoMode(screenwidth, screenheight, screenbbp, screenflags);
    
    }
    game::~game()
    {
        SDL_Quit();
    }
    
    void game::onexecute()
    {
        while(!done)
        {
            onthink();
            onupdate();
            onrender();
        }
    }
    
    void game::onthink()
    {
        while(SDL_PollEvent(&event))
        {
            if(event.type==SDL_QUIT)
                done=true;
    
            if(event.type==SDL_KEYDOWN)
                if(event.key.keysym.sym==SDLK_ESCAPE)
                    done=true;
        }
    }
    
    void game::onrender()
    {
        SDL_FillRect(screen, NULL, 0);
    
            SDL_Flip(screen);
    }
    
    int main(int argc, char* args[])
    {
        game game;
        game.onexecute();
    
        return 0;
    }
    Log
    Code:
    1>------ Build started: Project: re-write SDL pre pixel collision, Configuration: Debug Win32 ------
    1>  game.cpp
    1>LINK : fatal error LNK1561: entry point must be defined
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    Any ideas?

    Thanks for reading!

  2. #2
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    934
    SDL requires you to use argc and argv as the arguments to main, since you're using "args" instead it probably chokes on that. Replace your main with this:

    Code:
    int main(int argc, char *argv[])
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  3. #3
    Registered User
    Join Date
    May 2012
    Posts
    2
    Nop, same error after replace...

    I'm gonna give up on SDL and move to java..

    Thanks for the help!

  4. #4
    Registered User sfryett's Avatar
    Join Date
    Jul 2010
    Location
    London
    Posts
    4
    A couple of things:
    Code:
    #include "Games.h"
    Should that be game.h?

    Code:
    void game::onexecute()
    {
        while(!done)
        {
            onthink();
            onupdate();
            onrender();
        }
    }
    The onupdate() method has a declaration but no implementation.

    Otherwise compiles & runs fine (Xubuntu 12.04 / Codeblocks 10.05); have you set the compiler / linker options? Have you run other SDL programs okay?

    Quote Originally Posted by sdltutorials.com
    Before we start, I'd like to say that this is an advanced SDL tutorial. You should have experience with creating SDL applications and some basic knowledge of getting a program with it's libraries up and running.
    Cheers,
    Stu

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fread problems or memory problems
    By Lechuza in forum C Programming
    Replies: 1
    Last Post: 03-22-2009, 12:45 PM
  2. Replies: 17
    Last Post: 09-28-2008, 02:21 AM
  3. LINK : fatal error LNK1561: entry point must be defined
    By thestien in forum C++ Programming
    Replies: 18
    Last Post: 10-22-2006, 05:42 PM
  4. Linking problems, class problems
    By Kheila in forum C++ Programming
    Replies: 12
    Last Post: 11-22-2005, 12:47 AM
  5. I/O problems.
    By Skynet-systems in forum C++ Programming
    Replies: 10
    Last Post: 02-14-2005, 03:08 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21