Original Post
Hi everyone,
I am facing a very weird compiling error. I am using OpenGL with code::blocks IDE. However, I don't think that this problem is related to OpenGL at all.
I am using math.h header file. I have an GLfloat variable that contains an angle in degrees. However, when I use this angle for sin() or cos() functions it needs to be in radians. Hence, I created a separate class named "Misc" in a separate header file that has this conversion function
Misc.h
Misc.cpp
hence, whenever I call these functions anywhere in the program, I get compilation errors of "undefined reference to 'Misc::toRadians(float)' "
and "undefined reference to 'Misc::foo()' "
however, wherever I am calling these functions, I have checked that I am including this header file in that source file....
both Misc.h and Misc.cpp are in the same folder....
However, I noticed that I defined the functions in Misc class itself, then I have no errors, If I define these functions outside the class in the same header file then I get multiple definitions error....
I am completely struck and I can't figure out what I am doing wrong here...?
Thanks for any help, appreciate it....
I am facing a very weird compiling error. I am using OpenGL with code::blocks IDE. However, I don't think that this problem is related to OpenGL at all.
I am using math.h header file. I have an GLfloat variable that contains an angle in degrees. However, when I use this angle for sin() or cos() functions it needs to be in radians. Hence, I created a separate class named "Misc" in a separate header file that has this conversion function
Misc.h
#ifndef MISC_H_INCLUDED
#define MISC_H_INCLUDED
#include <GL\gl.h>
#include <GL\glu.h>
class Misc
{
public:
Misc() {}
static GLfloat toRadians(GLfloat degrees);
static void foo();
};
#endif // MISC_H_INCLUDED
Misc.cpp
#include "Misc.h"
GLfloat Misc::toRadians(GLfloat degrees)
{
return degrees * (3.14159265f / 180.0f);
}
void Misc::foo()
{
}
hence, whenever I call these functions anywhere in the program, I get compilation errors of "undefined reference to 'Misc::toRadians(float)' "
and "undefined reference to 'Misc::foo()' "
however, wherever I am calling these functions, I have checked that I am including this header file in that source file....
both Misc.h and Misc.cpp are in the same folder....
However, I noticed that I defined the functions in Misc class itself, then I have no errors, If I define these functions outside the class in the same header file then I get multiple definitions error....
I am completely struck and I can't figure out what I am doing wrong here...?
Thanks for any help, appreciate it....