Cannot Find Included Class

I have the following file (I did everything in the .h file as I think that is a much cleaner way to do this, I realize my compile times will increase. I am much more familiar with java than I am c++):

Panel.h:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef PANEL_H
#define PANEL_H

#include <string>
#include "Container.h"


using namespace std;

class Panel: public Container
{
    public: Panel()
    	: Container()
    {

    }

    public: virtual ~Panel();


    public: void setTitle(string title)
    {
    	 _title = title;
    }


    public: void draw()
	{
			glBegin( GL_QUADS );
				glColor4f( 0.0, 0.0, 0.0, 1.0 );

				//Draw square
				glVertex3f( 0, 0, 0 );
				glVertex3f( getWidth(), 0, 0 );
				glVertex3f( getWidth(), getHeight(), 0 );
				glVertex3f( 0, getHeight(), 0 );
			glEnd();

			glBegin( GL_LINE_STRIP );
				glColor4f( 0.5, 0.5, 0.5, 1.0 );

				//Draw square
				glVertex3f( 0, 0, 0 );
				glVertex3f( getWidth(), 0, 0 );
				glVertex3f( getWidth(), getHeight(), 0 );
				glVertex3f( 0, getHeight(), 0 );
				glVertex3f( 0, 0, 0 );
			glEnd();

		Container::draw();
	}


    private: string _title;
};

#endif // PANEL_H 


And panel derives from container as you see, yet I have the following problems with the file:
1
2
3
4
5
6
7
8
9
10
11
12
13
Description	Resource	Path	Location	Type
undefined reference to `Component::getWidth()'	Panel.h	/ChubbyEngine/src	line 44	C/C++ Problem
undefined reference to `Component::getHeight()'	Panel.h	/ChubbyEngine/src	line 45	C/C++ Problem
undefined reference to `Component::getWidth()'	Panel.h	/ChubbyEngine/src	line 35	C/C++ Problem
undefined reference to `Component::getHeight()'	Panel.h	/ChubbyEngine/src	line 36	C/C++ Problem
undefined reference to `Container::draw()'	Panel.h	/ChubbyEngine/src	line 50	C/C++ Problem
undefined reference to `Component::getWidth()'	Panel.h	/ChubbyEngine/src	line 45	C/C++ Problem
undefined reference to `Component::getHeight()'	Panel.h	/ChubbyEngine/src	line 46	C/C++ Problem
undefined reference to `Container::Container()'	Panel.h	/ChubbyEngine/src	line 13	C/C++ Problem
undefined reference to `Component::getWidth()'	Panel.h	/ChubbyEngine/src	line 34	C/C++ Problem
undefined reference to `Component::getHeight()'	Panel.h	/ChubbyEngine/src	line 35	C/C++ Problem
undefined reference to `Container::~Container()'	Panel.h	/ChubbyEngine/src	line 13	C/C++ Problem
undefined reference to `Container::~Container()'	Panel.h	/ChubbyEngine/src	line 18	C/C++ Problem



The class was obviously included so I am a bit stuck. I imagine this is related to this following issue, I have the following:

Container.h:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef CONTAINER_H
#define CONTAINER_H

#include <vector>

#include "Component.h"
#include "LayoutManager.h"

using namespace std;

class LayoutManager;

class Container: public Component
{
    public:
        Container();
        virtual ~Container();

        void add(Component *pComponent);
        vector<Component*> &getComponents();
        void setLayout(LayoutManager *layoutManager);

        void handleEvents(SDL_Event event);

        void draw();
    private:
        vector<Component*> _components;
        LayoutManager    *_pLayoutManager;
};

#endif // CONTAINER_H 


And if I didn't make the forward declaration to LayoutManager then it was unable to find the class regardless of me including it.

I have the following system specs:
Windows 7 x64
Eclipse 4.2.x
MingW (latest) with SDL (latest) dev libraries
and this is an SDL project if that matters

also, here is a link to my workspace if that is of any help:
https://dl.dropbox.com/u/8241732/workspace.zip

Thank you for any help at all you can give me.
Brandon
Last edited on
Try to have your your includes above your ifndef statements and see if that makes a difference
@Amac89 nope, didn't fix the issue, thanks though!
Did you link to the library that provides all the "component" functions?
@BlackSheep well, its just a class I created in the same project
And if I didn't make the forward declaration to LayoutManager then it was unable to find the class regardless of me including it


It seems something is wrong, there shouldn't be need for forward declaration, it must work by including LayoutManager.h, I think you have got another mistake in your project, if you give the whole project I think I can help somehow.
The error you get is a linker error. The linker can't find the definitions of Component::getWidth(), Component::getHeight(), and the rest of the functions in the list. Make sure you have defined the functions somewhere. If you defined the functions in a source file, make sure that you have added the source files to your project.
Last edited on
@TTT Sure thing! https://dl.dropbox.com/u/8241732/workspace.zip Thanks!

@Peter87 Yeah, I double checked and they exist. I am beginning to think it is something funky eclipse is doing during the build process, I am thinking I may want to try importing the project into something like codeblocks to see if that makes all the problems disappear.
Topic archived. No new replies allowed.