I am using Visual C++ .NET 2003 and included some header files that I wrote for an earlier project. I will be using these header files in several future projects, so instead of adding a copy to each project, I added the path of the header files to the "Additional Include Directories" under Project Properties (C/C++ | General).
When I try to use the classes in the header files, for example one class is called MyVector, I get the following error:
nofb error LNK2019: unresolved external symbol "public: __thiscall MyVector::~MyVector(void)" (??1MyVector@@QAE@XZ) referenced in function "public: __thiscall Scene::Scene(void)" (??0Scene@@QAE@XZ)
But I noticed that this error only happens for functions that are defined in MyVector.cpp and not for functions that are defined in MyVector.h (such as simple "set" and "get" functions). I've spent all night playing with the settings and searching MSDN -- does anyone have any suggestions? Thanks!!
Here is an excerpt of my code if that helps...
Code:// ====== Scene.h====== #ifndef SCENE_H_ #define SCENE_H_ #include <MyVector.h> class Scene { public: Scene(); ~Scene(); private: MyVector *points; int numPoints; }; #endif // ====== Scene.cpp ====== #include "Scene.h" Scene::Scene() { numPoints = 14 * 3; // The following functions yield linker errors (LNK2019) points = new MyVector[numPoints]; points[0].normalize(); // The following functions do not yield linker errors points[0].setElement(0,2.0f); // test build errors float i = points[0].getElement(0); int j = points[0].getLength(); } // end default constructor Scene::~Scene() { delete [] points; // Yields linker errors } // end deconstructor // ====== MyVector.h ====== #ifndef MYVECTOR_H_ #define MYVECTOR_H_ class MyVector { public: MyVector(); // Implemented in MyVector.cpp ~MyVector(); // Implemented in MyVector.cpp void normalize(); // Implemented in MyVector.cpp int getLength() { return length; } float getElement(int i) { return v[i]; } void setElement (int i, float c) { v[i] = c; } private: float *v; int length; }; #endif