first time asking.
Here's the deal:
I have a helper class (at least now it's a class) that has several math functions, that I use throughout the project.
#ifndef CUSTOM_UTILS_H
#define CUSTOM_UTILS_H
//---------------------------------------------------------
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
class cUtil {
public:
static int utilsRandom(int from, int to);
static double utilsRandom(double from, double to);
static double giveAngle(double x, double y);
static double FoV(double cx, double cy,
double fx, double fy,
double tx, double ty,
double radius);
};
//---------------------------------------------------------
#endif
Implementation:
#define _USE_MATH_DEFINES
#include "customUtils.h"
//---------------------------------------------------------
int cUtil::utilsRandom(int from, int to) {
if (from == to) {
return from;
}
return (rand() % (to - from)) + from;
}
//---------------------------------------------------------
double cUtil::utilsRandom(double from, double to) {
...
}
//---------------------------------------------------------
double cUtil::giveAngle(double x, double y) {
...
}
//---------------------------------------------------------
double cUtil::FoV(double cx, double cy,
double fx, double fy,
double tx, double ty,
double radius) {
...
}
//---------------------------------------------------------
(removed the 3 bodies to save space for the post)
Now, when I use it , let's say, in a class called 'creature' I include the customUtils.h file in the header of 'creature'. And use any of the 4 functions like so: cUtil::func_name(). Sometimes I get an unresolved external error such as
LNK2001: unresolved external symbol "public: static double __cdecl cUtil::utilsRandom
(double,double)" (?utilsRandom@cUtil@@SANNN@Z) C:\Users\Rockstrongo\Documents\Projects
\nnEvo\nnEvo\net.obj
It appears for all functions in cUtil and for all classes that use those functions.
I said it sometimes appears, because it just does that - I'd be rebuilding the project and it would resurface. To scrub it again I would change some part of cUtils code, or the way it is included in other classes or anything that it would get it running again. For some time, cleaning->compiling the customUtils.cpp->then building the rest worked, but not any more.
To an untrained eye like mine this appears to be completely random and I'm all out off straws to grasp. I'm using Microsoft Visual Studio 2010. It's a console project using openGL and glut.