Game Development Community

Unresolved Externals when using HashMap [Resolved]

by Alex Poli · in Torque 2D Professional · 02/07/2014 (3:22 pm) · 2 replies

I have recently been trying to use a HashMap object to get information about different points around my map. Unfortunately I keep getting the following error:
Error	2	error LNK2019: unresolved external symbol "protected: __thiscall ConsoleObject::ConsoleObject(class ConsoleObject const &)" (??0ConsoleObject@@IAE@ABV0@@Z) referenced in function "public: __thiscall SimObject::SimObject(class SimObject const &)" (??0SimObject@@QAE@ABV0@@Z)	C:UsersAlexTorque2dTorque2DenginecompilersVisualStudio 2012MapGeneration.obj	Torque2D

Error	3	error LNK1120: 1 unresolved externals	C:UsersAlexDocumentsLightTorque2D.exe	Torque2D

Right now my implementation looks like the following:
HashMap<Point2D, SimObject> vertLookup;
Point2D vertPoint;

// ...
//code that does stuff with tmpVert[] SimObject and xValues and yValues
// ...

vertPoint.x = xValues[i];
vertPoint.y = yValues[i];
vertLookup.insert(vertPoint, tmpVert[i]);

What I am wondering is if this is a problem with the engine or with how I am using the HashMap.

#1
02/07/2014 (5:33 pm)
You are directly using an instance of a SimObject, and since SimObject doesn't have an implemented copy constructor (to prevent weird things from happening) the compiler rightfully is failing.

Instead it is a better idea to use either SimObject* or if you want to use reference counting, a variant of SimObjectPtr.
#2
02/07/2014 (6:17 pm)
Thanks for the tip, that fixed it!