Hi everyone. I'm having a problem integrating the standard libraries iostream and string into my DGDK project ( or vice versa DGDK into my project). Here is the non-DGDK source:
#include <iostream>
#include <string>
#include <limits>
#include "windows.h"
#include "DarkGDK.h"
using namespace std;
void DarkGDK( void )
{
int clips = 5;
string SHOOT;
int aftrsht = 50;
int temp = 0;
int temp1 = 0;temp = aftrsht*clips;
while ( 1 )
{
cout << "total ammo: " << temp <<", ammo left in clip: "<< aftrsht <<", clips: " << clips << endl;
cin >> SHOOT;
//"shoot"
if ( SHOOT == "shoot" )
{
aftrsht = aftrsht - 1;
temp = temp - 1;
}
//exiting
if ( SHOOT == "exit" )
{
return;
}
//reloading
if ( SHOOT == "reload" )
{
aftrsht = 50;
clips = clips - 1;
}
if ( aftrsht <= 0 && clips > 0 )
{
aftrsht = 50; clips = clips - 1;
}
if ( clips <= 0 && aftrsht <= 0 )
{
return;
}
if ( clips == 0 )
{
clips = 0;
}
}
//cout << "Press ENTER to continue...";
//cin.ignore( std::numeric_limits<std::streamsize>::max(), 'n' );
return;
}
int main ()
{
DarkGDK ();
}
and here is the source when i attempt to include a DGDK function:
#include <iostream>
#include <string>
#include <limits>
#include "windows.h"
#include "DarkGDK.h"
using namespace std;
void DarkGDK( void )
{
int clips = 5;
string SHOOT;
int aftrsht = 50;
int temp = 0;
int temp1 = 0;temp = aftrsht*clips;
while ( LoopGDK() )
{
cout << "total ammo: " << temp <<", ammo left in clip: "<< aftrsht <<", clips: " << clips << endl;
cin >> SHOOT;
//"shoot"
if ( dbMouseClick() )
{
aftrsht = aftrsht - 1;
temp = temp - 1;
}
//exiting
if ( SHOOT == "exit" )
{
return;
}
//reloading
if ( SHOOT == "reload" )
{
aftrsht = 50;
clips = clips - 1;
}
if ( aftrsht <= 0 && clips > 0 )
{
aftrsht = 50; clips = clips - 1;
}
if ( clips <= 0 && aftrsht <= 0 )
{
return;
}
if ( clips == 0 )
{
clips = 0;
}
}
//cout << "Press ENTER to continue...";
//cin.ignore( std::numeric_limits<std::streamsize>::max(), 'n' );
return;
}
int main ()
{
DarkGDK ();
}
...and here is the error message when compiling the last source code:
------ Build started: Project: hudsandammo, Configuration: Debug Win32 ------
Compiling...
source.cpp
Linking...
LINK : C:Documents and SettingsNeil's AccountMy DocumentsVisual Studio 2008ProjectshudsandammoDebughudsandammo.exe not found or not built by the last incremental link; performing full link
display.lib(CGfxC.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
display.lib(CGfxC.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
image.lib(CImageC.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
image.lib(CImageC.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
basic3D.lib(DBOFormat.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
basic3D.lib(DBOFormat.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
basic3D.lib(Universe.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
basic3D.lib(Universe.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
basic3D.lib(CSG.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
basic3D.lib(CSG.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
basic3D.lib(cLightMaps.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
basic3D.lib(cLightMaps.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
basic3D.lib(NVMeshMenderD3DX.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
basic3D.lib(NVMeshMenderD3DX.obj) : error LNK2005: "bool __cdecl std::operator==<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (??$?8DU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@PBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
basic3D.lib(NVMeshMenderD3DX.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
basic3D.lib(CBSPTree.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
basic3D.lib(CBSPTree.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
basic3D.lib(CCompiler.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
basic3D.lib(CCompiler.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
basic3D.lib(ProcessHSR.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
basic3D.lib(ProcessHSR.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
world.lib(Patch.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
world.lib(Patch.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
multiplayer.lib(CNetwork.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
multiplayer.lib(CNetwork.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
system.lib(dxdiaginfo.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
system.lib(dxdiaginfo.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
convx.lib(ConvX.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
convx.lib(ConvX.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
convmd3.lib(ConvMD3.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
convmd3.lib(ConvMD3.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
convmdl.lib(ConvMDL.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
convmdl.lib(ConvMDL.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
libcpmt.lib(string.obj) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
libcpmt.lib(string.obj) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
LIBCMT.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in MSVCRTD.lib(MSVCR90D.dll)
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
C:Documents and SettingsNeil's AccountMy DocumentsVisual Studio 2008ProjectshudsandammoDebughudsandammo.exe : fatal error LNK1169: one or more multiply defined symbols found
Build log was saved at "file://c:Documents and SettingsNeil's AccountMy DocumentsVisual Studio 2008ProjectshudsandammohudsandammoDebugBuildLog.htm"
hudsandammo - 37 error(s), 2 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Any help?
Note: the code only utilizing the standard libraries compiles perfectly fine.
...