TGB 1.5 and cout - linker error?
by baylor wetzel · in Torque Game Builder · 11/09/2007 (11:00 am) · 3 replies
Color me confused. i took my stock TGB 1.5 source, opened the VS 2005 solution, added a ConObject, built and was happy
Step 2 was to add a working and tested .hpp and .cpp from another (non-Torque) project. It compiles but doesn't link - "error LNK2005: "void * __cdecl operator new(unsigned int,void *)" (??2@YAPAXIPAX@Z) already defined in winMemory.obj libcpmt.lib " along with "libcpmt.lib(locale0.obj) : error LNK2005: "void * __cdecl operator new(unsigned int,void *)" (??2@YAPAXIPAX@Z) already defined in winMemory.obj
../../../tgb/TorqueGameBuilder_DEBUG.exe : fatal error LNK1169: one or more multiply defined symbols found"
i can fix it - by commenting out the two cout lines. The lines are really simple - cout << "my error\n";
It seems like such a silly little error, and i can get rid of the lines (there's only 2, used to catch malloc errors), but i'm confused as to why it should happen. Especially since the error i'm given doesn't seem to have anything in common with cout
Cleaning/rebuild solution doesn't help
There's only one search result on Google for this error, and it's a Garage Games post for the pre-Visual Studio 2005 3D engine that says Torque can't use STL without quite a few changes to the core Torque memory allocation system, but a)it's not clear it applies to newer code (either Studio of Torque; one comment seems to say it's not an issue in VS2005) and b)it's not for TGB. i also don't see how it applies to cout. i do have a "using namespace std" statement in the file but don't use any STL (cout isn't STL is it?)
As a check, though, i added a map (it was next on my todo list). That gets the same linker error. So maybe it is an STL thing. If so, i'm not sure how to proceed. i suppose i either need to get STL and TGB to work together (if that's the issue) or find a non-STL hashtable (there's one in my original code but i don't trust it; i think it might have a memory leak). I'm willing to do all the patching of the TGB 1.5 code if i absolutely have to to get a hashtable but i'm hoping there's an easier solution here
Any ideas?
Step 2 was to add a working and tested .hpp and .cpp from another (non-Torque) project. It compiles but doesn't link - "error LNK2005: "void * __cdecl operator new(unsigned int,void *)" (??2@YAPAXIPAX@Z) already defined in winMemory.obj libcpmt.lib " along with "libcpmt.lib(locale0.obj) : error LNK2005: "void * __cdecl operator new(unsigned int,void *)" (??2@YAPAXIPAX@Z) already defined in winMemory.obj
../../../tgb/TorqueGameBuilder_DEBUG.exe : fatal error LNK1169: one or more multiply defined symbols found"
i can fix it - by commenting out the two cout lines. The lines are really simple - cout << "my error\n";
It seems like such a silly little error, and i can get rid of the lines (there's only 2, used to catch malloc errors), but i'm confused as to why it should happen. Especially since the error i'm given doesn't seem to have anything in common with cout
Cleaning/rebuild solution doesn't help
There's only one search result on Google for this error, and it's a Garage Games post for the pre-Visual Studio 2005 3D engine that says Torque can't use STL without quite a few changes to the core Torque memory allocation system, but a)it's not clear it applies to newer code (either Studio of Torque; one comment seems to say it's not an issue in VS2005) and b)it's not for TGB. i also don't see how it applies to cout. i do have a "using namespace std" statement in the file but don't use any STL (cout isn't STL is it?)
As a check, though, i added a map (it was next on my todo list). That gets the same linker error. So maybe it is an STL thing. If so, i'm not sure how to proceed. i suppose i either need to get STL and TGB to work together (if that's the issue) or find a non-STL hashtable (there's one in my original code but i don't trust it; i think it might have a memory leak). I'm willing to do all the patching of the TGB 1.5 code if i absolutely have to to get a hashtable but i'm hoping there's an easier solution here
Any ideas?
About the author
#2
iostream redefines the operator "new," which is already defined. Hence the linker error. Instead of using cout, use something like the Con::printf feature already available.
11/09/2007 (12:42 pm)
This caught me too.iostream redefines the operator "new," which is already defined. Hence the linker error. Instead of using cout, use something like the Con::printf feature already available.
#3
So iostream redefines new, huh? Did not know that. Wonder if that's a new thing
By any chance, do you know if you can print colors? The escape sequences like \c1 don't seem to do it. Oh well, i'll go look through the code to see if i can find an example
11/09/2007 (1:27 pm)
You guys are great! Remind me to name my first born child after you. Of course, i'm not sure Ashley's going to like it. You know how teenagers getSo iostream redefines new, huh? Did not know that. Wonder if that's a new thing
By any chance, do you know if you can print colors? The escape sequences like \c1 don't seem to do it. Oh well, i'll go look through the code to see if i can find an example
Associate Phillip O'Shea
Violent Tulip
You must ensure that the argument is a char variable type. If not you can use dSprintf to output a nice lil string for you.