undefined reference to

Hey I am having some problem with my code I just cant figure it out.
I keep getting undefined reference to `Object::LoadTexture(char const*)' and i cant seem to figure it out.

The Full Error

/tmp/cc81gq9q.o: In function `Object::draw()':
Object.cpp:(.text+0xd4): undefined reference to `Object::LoadTexture(char const*)'
collect2: ld returned 1 exit status


Here is my code

object.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#ifndef  OBJECT_H   // preprocessor directive
#define  OBJECT_H
#include <GL/glfw.h>

class Object
{
	        private:
                float x, y;
     
	
	
   public:
                
                float getX(void);
                float getY(void);               
                void update();
                void draw();
               	GLuint LoadTexture(const char* TextureName);
                
};

 #endif 




////////////////////////////////////////////////////////

Object.cpp



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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#include "Object.h"







/**
	Return X location
*/
float Object::getX(void)
{
	return x;
}

/**
	Return y location
*/
float Object::getY(void)
{
	return y;
}



GLuint LoadTexture(const char* TextureName)

{

   GLuint Texture;  //variable for texture

   glGenTextures(1,&Texture); //allocate the memory for texture

   glBindTexture(GL_TEXTURE_2D,Texture); //Binding the texture


   if(glfwLoadTexture2D(TextureName, GLFW_BUILD_MIPMAPS_BIT)){

      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

      glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);

      return Texture;

   }else return -1;

}


/**
	Player's update function
*/
 void Object::update()
{
	
	
	
}


 void Object::draw()
{
	
	
	glPushMatrix();
	
     	
  	GLuint text2D;

    text2D = LoadTexture("pinkluma.png"); //loading image for texture
  

    glEnable(GL_TEXTURE_2D); //Enable texture

    glBindTexture(GL_TEXTURE_2D,text2D);//Binding texture


    glPushMatrix();

    glBegin(GL_POLYGON); //Begin quadrilateral coordinates

    glNormal3f(0.0f, 0.0f, 1.0f);//normal vector

  	glTexCoord2f(0.0f, 0.0f); //Texture co-ordinate origin or  lower left corner

 	glVertex3f(-10.0f,-11.0f,5.0f);

  	glTexCoord2f(1.0f, 0.0f); //Texture co-ordinate lower right corner

  	glVertex3f(10.0f,-11.0f,5.0f);

  	glTexCoord2f(1.0f, 1.0f);//Texture co-ordinate top right corner

  	glVertex3f(10.0f,-1.0f,-15.0f);

  	glTexCoord2f(0.0f, 1.0f);//Texture co-ordinate top left corner

  	glVertex3f(-10.0f,-1.0f,-15.0f);
	

 	 glEnd(); //End quadrilateral coordinates

  	glPopMatrix();

  	glDisable(GL_TEXTURE_2D);

	glPopMatrix();
	
	
	glPopMatrix();

  	glDisable(GL_TEXTURE_2D);



    glEnable(GL_TEXTURE_2D);

    glBindTexture(GL_TEXTURE_2D,text2D);

    glPushMatrix();


    glBegin(GL_POLYGON);

    glNormal3f(0.0f, 0.0f, 1.0f);

  	glTexCoord2f(0.0f, 0.0f);//Texture co-ordinate origin or lower left corner

    glVertex3f(-10.0f,-1.0f,-15.0f);

    glTexCoord2f(10.0f, 0.0f); //Texture co-ordinate for repeating image ten times form

    //origin to lower right corner

    glVertex3f(10.0f,-1.0f,-15.0f);

    glTexCoord2f(10.0f, 10.0f);//repeat texture ten times form lower to top right corner.

    glVertex3f(10.0f,15.0f,-15.0f);

    glTexCoord2f(0.0f, 10.0f);//repeat texture ten time form top right to top left corner.

    glVertex3f(-10.0f,15.0f,-15.0f);

    glEnd();

    glPopMatrix();

    glDisable(GL_TEXTURE_2D); //Disable the texture
    
    glfwSwapBuffers();
    


}


Oh and it my compiling i do this (g++ Main.cpp Player.cpp Object.cpp -o Game -lGL -lglfw -lBox2D)

thanks for the help
Last edited on
First format your code by highlighting it and clicking the <> button. Then post the entire error message.
Topic archived. No new replies allowed.