Game Development Community

Use of STL

by Telmo Menezes · in Torque Game Engine · 01/31/2005 (11:16 am) · 3 replies

Hi,

I am writing new code to compiles together with torque. I use STL (Standard Template Library). When I build the executable using the STL an error in the linker occurs:

error LNK2005: "void * __cdecl operator new(unsigned int,void *)" (??2@YAPAXIPAX@Z) already defined in winMemory.obj

The operator is defined in the winMemory.cc file of torque Platform Specific files.

Does anyone know how to get STL to work with Torque?

Best Regards,
Telmo Menezes

#1
01/31/2005 (11:29 am)
Hey Telmo,

It doesnt out of the box. The TGE memory manager redefines new() and other methods, and that doesnt play nice with STL

Your best bet is to turn off the TGE memory manager. There are several threads on how to do this with a single define. There is also (hopefully) soon a little patch to allow usage of STL and the memory manager next to each other. But that patch is currently no for all platforms afaik.
#2
01/31/2005 (5:21 pm)
Hey Telmo,

Ran into the same problem trying to use MS STL based streams. Might sound too simple, but I just commented out the offending code in winMemory.cc art around line 41.

////--------------------------------------
//void* FN_CDECL operator new(dsize_t, void* ptr) 
//{
//   return (ptr);
//}


I believe the MS code implementation is identical, so no foul. At any rate, I have been running just fine since.

Hope this is of help,

Kristen.
#3
01/31/2005 (6:43 pm)
@Telmo - I've sucessfully used the header linked at the bottom of this resource to get STL working in a Torque project.