2 Replies - 1765 Views - Last Post: 23 September 2010 - 05:32 AM Rate Topic: -----

#1 seealsoidiot  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 23-September 10

Static Class Method problems (C++/SDL)

Posted 23 September 2010 - 05:21 AM

Hey all. First time poster, long time lurker. Anyways, I'm having a bit of trouble with a simple game framework using C++ and SDL. My problem has something to do with an undefined reference to my cGraphics class apparently.

class cGraphics{
    public:
        cGraphics();

        static SDL_Surface* Load_IMG( std::string _filename );
        static bool Draw_IMG( SDL_Surface* _dest, SDL_Surface* _src, int _x, int _y );
};


Here is my graphics class, which is pretty simple. But when I try to use, say, my Load_IMG() method in my cEngine::On_Init() method:
bool cEngine::On_Init(){
    ...
    //load image into m_test surface
    if( ( m_test = cGraphics::Load_IMG( "./Data/gfx/test.bmp" ) ) == NULL ){
        return false;
    }
    ...
}


I receive an 'undefined reference to cGraphics::Load_IMG()' error. BTW, I am including the "graphics.h" file in my "engine.h" file. Any help would be greatly appreciated, and I hope I posted enough info. If not just ask for more. =)

Is This A Good Question/Topic? 0
  • +

Replies To: Static Class Method problems (C++/SDL)

#2 sarmanu  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 966
  • View blog
  • Posts: 2,362
  • Joined: 04-December 09

Re: Static Class Method problems (C++/SDL)

Posted 23 September 2010 - 05:26 AM

Did you actually implement "cGraphics::Load_IMG" function? Because it appears that the linker can't find the body of this function. It is only prototyped.
Was This Post Helpful? 0
  • +
  • -

#3 seealsoidiot  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 23-September 10

Re: Static Class Method problems (C++/SDL)

Posted 23 September 2010 - 05:32 AM

Yes, I implemented it. And I found the problem, somehow my makefile didn't save and it wasn't linking my "graphics.cpp"? Lesson learned: Sleep. lol Thanks though. >.<

edit: Actually, you were right. lol It wasn't linking correctly.

This post has been edited by seealsoidiot: 23 September 2010 - 05:36 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1