Errors driving me crazy
ok.
I am getting unresolved linker errors through my project. i get these errors if i remove my CAppCLass.cpp file from the project, but i leave the header. If i add the cpp file, i get a whole bunch more errors, but this time they tell me that "symbol" is already defined in main.obj. i read the artical here on Gamedev, but it wasn''t much help.
Here are the errors that i get if i leave out CAppClass.cpp:
main.obj : error LNK2001: unresolved external symbol "public: unsigned int __thiscall CAppClass::Run(void)" (?Run@CAppClass@@QAEIXZ)
main.obj : error LNK2001: unresolved external symbol "public: __thiscall CAppClass::~CAppClass(void)" (??1CAppClass@@QAE@XZ)
main.obj : error LNK2001: unresolved external symbol "public: bool __thiscall CAppClass::Initialize(struct HINSTANCE__ *,char *,int)" (?Initialize@CAppClass@@QAE_NPAUHINSTANCE__@@PADH@Z)
main.obj : error LNK2001: unresolved external symbol "public: __thiscall CAppClass::CAppClass(void)" (??0CAppClass@@QAE@XZ)
Debug/VectThunder.exe : fatal error LNK1120: 4 unresolved externals
And here are the errors i get if i leave it in. (only a sample
CAppClass.obj : error LNK2005: "public: __thiscall DirectX::DirectX(void)" (??0DirectX@@QAE@XZ) already defined in main.obj
CAppClass.obj : error LNK2005: "public: virtual __thiscall DirectX::~DirectX(void)" (??1DirectX@@UAE@XZ) already defined in main.obj
CAppClass.obj : error LNK2005: "public: __thiscall CVector::CVector(void)" (??0CVector@@QAE@XZ) already defined in main.obj
CAppClass.obj : error LNK2005: "public: __thiscall CVector::CVector(float,float)" (??0CVector@@QAE@MM@Z) already defined in main.obj
CAppClass.obj : error LNK2005: "public: __thiscall CVector::CVector(float,float,unsigned long)" (??0CVector@@QAE@MMK@Z) already defined in main.obj
can anyone offer some insight as to what i might be dong wrong?
EOF
------------------------------------------VOTE Patrick O'GradyWrite in Presidential CandidateThe Candidate who Cares.
You aren''t including that CAppClass.cpp anywhere in your source
are you? To use the class only include the header of it where
the implentation should be. Also, CAppClass must be included
in the project otherwhise it won''t compile the functions along
with the program and you get "unresolved external" errors.
There''s an article on the site about managing source & header files - you should proabably read it.
Basically, .cpp are the only things that get compiled. After it''s compiled, all the name referneces are stitched up (by the linker). Of you have the same cpp in the project twice, there will be duplicate entries and the linker gets confused.
The .cpp''s should include the .h''s.
Basically, .cpp are the only things that get compiled. After it''s compiled, all the name referneces are stitched up (by the linker). Of you have the same cpp in the project twice, there will be duplicate entries and the linker gets confused.
The .cpp''s should include the .h''s.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
There''s an article on the site about managing source & header files - you should proabably read it.
Basically, .cpp are the only things that get compiled. After it''s compiled, all the name referneces are stitched up (by the linker). Of you have the same cpp in the project twice, there will be duplicate entries and the linker gets confused.
You can also have problems if you put source code in the header. The header is for declarations, void foo(); and the source file is for defintions, void foo(){cout "Foo-ah!";}
Basically, .cpp are the only things that get compiled. After it''s compiled, all the name referneces are stitched up (by the linker). Of you have the same cpp in the project twice, there will be duplicate entries and the linker gets confused.
You can also have problems if you put source code in the header. The header is for declarations, void foo(); and the source file is for defintions, void foo(){cout "Foo-ah!";}
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
There''s an article on the site about managing source & header files - you should proabably read it.
Basically, .cpp are the only things that get compiled. After it''s compiled, all the name referneces are stitched up (by the linker). Of you have the same cpp in the project twice, there will be duplicate entries and the linker gets confused.
You can also have problems if you put source code in the header. The header is for definitions, void foo(); and the source file is for declarations, void foo(){cout "Foo-ah!";}
Basically, .cpp are the only things that get compiled. After it''s compiled, all the name referneces are stitched up (by the linker). Of you have the same cpp in the project twice, there will be duplicate entries and the linker gets confused.
You can also have problems if you put source code in the header. The header is for definitions, void foo(); and the source file is for declarations, void foo(){cout "Foo-ah!";}
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
so then i need to figure out why it is giving me the second set of errors...
all of my class'' have inclusion protection...
#ifndef blah
#define blah
class blah
#endif
shoudl i post code? if so, what shoudl i post?
here are the errors i get if i include CAppCLass.cpp into the project:
CAppClass.obj : error LNK2005: "public: __thiscall DirectX::DirectX(void)" (??0DirectX@@QAE@XZ) already defined in main.obj
CAppClass.obj : error LNK2005: "public: virtual __thiscall DirectX::~DirectX(void)" (??1DirectX@@UAE@XZ) already defined in main.obj
CAppClass.obj : error LNK2005: "public: __thiscall CVector::CVector(void)" (??0CVector@@QAE@XZ) already defined in main.obj
CAppClass.obj : error LNK2005: "public: __thiscall CVector::CVector(float,float)" (??0CVector@@QAE@MM@Z) already defined in main.obj
CAppClass.obj : error LNK2005: "public: __thiscall CVector::CVector(float,float,unsigned long)" (??0CVector@@QAE@MMK@Z) already defined in main.obj
CAppClass.obj : error LNK2005: "public: __thiscall CVector::~CVector(void)" (??1CVector@@QAE@XZ) already defined in main.obj
CAppClass.obj : error LNK2005: "public: __thiscall CTextLog::CTextLog(void)" (??0CTextLog@@QAE@XZ) already defined in main.obj
CAppClass.obj : error LNK2005: "public: __thiscall CTextLog::CTextLog(char *)" (??0CTextLog@@QAE@PAD@Z) already defined in main.obj
CAppClass.obj : error LNK2005: "public: __thiscall CTextLog::~CTextLog(void)" (??1CTextLog@@QAE@XZ) already defined in main.obj
CAppClass.obj : error LNK2005: "public: bool __thiscall CTextLog::Init(char *)" (?Init@CTextLog@@QAE_NPAD@Z) already defined in main.obj
CAppClass.obj : error LNK2005: "public: void __thiscall CTextLog::WriteSystemError(char *)" (?WriteSystemError@CTextLog@@QAEXPAD@Z) already defined in main.obj
CAppClass.obj : error LNK2005: "public: void __thiscall CTextLog::WriteText(char *)" (?WriteText@CTextLog@@QAEXPAD@Z) already defined in main.obj
CAppClass.obj : error LNK2005: "public: void __thiscall CTextLog::operator<<(char *)" (??6CTextLog@@QAEXPAD@Z) already defined in main.obj
CAppClass.obj : error LNK2005: "public: class CVector __thiscall CMath::GetRotation(class CVector,class CVector)" (?GetRotation@CMath@@QAE?AVCVector@@V2@0@Z) already defined in main.obj
CAppClass.obj : error LNK2005: "public: bool __thiscall CMath::IsCollision(class BaseVectorObject *,class BaseVectorObject *)" (?IsCollision@CMath@@QAE_NPAVBaseVectorObject@@0@Z) already defined in main.obj
CAppClass.obj : error LNK2005: "bool g_bContinue" (?g_bContinue@@3_NA) already defined in main.obj
CAppClass.obj : error LNK2005: "char const * const TheAppClass" (?TheAppClass@@3PBDB) already defined in main.obj
CAppClass.obj : error LNK2005: "protected: static struct IDirect3DDevice8 * D3D::LPD3D" (?LPD3D@D3D@@1PAUIDirect3DDevice8@@A) already defined in main.obj
CAppClass.obj : error LNK2005: "public: static struct IDirectInput8A * DirectX::DIP" (?DIP@DirectX@@2PAUIDirectInput8A@@A) already defined in main.obj
CAppClass.obj : error LNK2005: "class VT * vt" (?vt@@3PAVVT@@A) already defined in main.obj
CAppClass.obj : error LNK2001: unresolved external symbol "public: bool __thiscall VT::Init(struct HWND__ *,struct HINSTANCE__ *,class CTextLog *)" (?Init@VT@@QAE_NPAUHWND__@@PAUHINSTANCE__@@PAVCTextLog@@@Z)
CAppClass.obj : error LNK2001: unresolved external symbol "public: bool __thiscall VT::Run(void)" (?Run@VT@@QAE_NXZ)
i am f''in lost!
EOF
all of my class'' have inclusion protection...
#ifndef blah
#define blah
class blah
#endif
shoudl i post code? if so, what shoudl i post?
here are the errors i get if i include CAppCLass.cpp into the project:
CAppClass.obj : error LNK2005: "public: __thiscall DirectX::DirectX(void)" (??0DirectX@@QAE@XZ) already defined in main.obj
CAppClass.obj : error LNK2005: "public: virtual __thiscall DirectX::~DirectX(void)" (??1DirectX@@UAE@XZ) already defined in main.obj
CAppClass.obj : error LNK2005: "public: __thiscall CVector::CVector(void)" (??0CVector@@QAE@XZ) already defined in main.obj
CAppClass.obj : error LNK2005: "public: __thiscall CVector::CVector(float,float)" (??0CVector@@QAE@MM@Z) already defined in main.obj
CAppClass.obj : error LNK2005: "public: __thiscall CVector::CVector(float,float,unsigned long)" (??0CVector@@QAE@MMK@Z) already defined in main.obj
CAppClass.obj : error LNK2005: "public: __thiscall CVector::~CVector(void)" (??1CVector@@QAE@XZ) already defined in main.obj
CAppClass.obj : error LNK2005: "public: __thiscall CTextLog::CTextLog(void)" (??0CTextLog@@QAE@XZ) already defined in main.obj
CAppClass.obj : error LNK2005: "public: __thiscall CTextLog::CTextLog(char *)" (??0CTextLog@@QAE@PAD@Z) already defined in main.obj
CAppClass.obj : error LNK2005: "public: __thiscall CTextLog::~CTextLog(void)" (??1CTextLog@@QAE@XZ) already defined in main.obj
CAppClass.obj : error LNK2005: "public: bool __thiscall CTextLog::Init(char *)" (?Init@CTextLog@@QAE_NPAD@Z) already defined in main.obj
CAppClass.obj : error LNK2005: "public: void __thiscall CTextLog::WriteSystemError(char *)" (?WriteSystemError@CTextLog@@QAEXPAD@Z) already defined in main.obj
CAppClass.obj : error LNK2005: "public: void __thiscall CTextLog::WriteText(char *)" (?WriteText@CTextLog@@QAEXPAD@Z) already defined in main.obj
CAppClass.obj : error LNK2005: "public: void __thiscall CTextLog::operator<<(char *)" (??6CTextLog@@QAEXPAD@Z) already defined in main.obj
CAppClass.obj : error LNK2005: "public: class CVector __thiscall CMath::GetRotation(class CVector,class CVector)" (?GetRotation@CMath@@QAE?AVCVector@@V2@0@Z) already defined in main.obj
CAppClass.obj : error LNK2005: "public: bool __thiscall CMath::IsCollision(class BaseVectorObject *,class BaseVectorObject *)" (?IsCollision@CMath@@QAE_NPAVBaseVectorObject@@0@Z) already defined in main.obj
CAppClass.obj : error LNK2005: "bool g_bContinue" (?g_bContinue@@3_NA) already defined in main.obj
CAppClass.obj : error LNK2005: "char const * const TheAppClass" (?TheAppClass@@3PBDB) already defined in main.obj
CAppClass.obj : error LNK2005: "protected: static struct IDirect3DDevice8 * D3D::LPD3D" (?LPD3D@D3D@@1PAUIDirect3DDevice8@@A) already defined in main.obj
CAppClass.obj : error LNK2005: "public: static struct IDirectInput8A * DirectX::DIP" (?DIP@DirectX@@2PAUIDirectInput8A@@A) already defined in main.obj
CAppClass.obj : error LNK2005: "class VT * vt" (?vt@@3PAVVT@@A) already defined in main.obj
CAppClass.obj : error LNK2001: unresolved external symbol "public: bool __thiscall VT::Init(struct HWND__ *,struct HINSTANCE__ *,class CTextLog *)" (?Init@VT@@QAE_NPAUHWND__@@PAUHINSTANCE__@@PAVCTextLog@@@Z)
CAppClass.obj : error LNK2001: unresolved external symbol "public: bool __thiscall VT::Run(void)" (?Run@VT@@QAE_NXZ)
i am f''in lost!
EOF
------------------------------------------VOTE Patrick O'GradyWrite in Presidential CandidateThe Candidate who Cares.
The errors you have are usually caused by a function being
defined multiple times between the .CPP sources. You can''t
have a function defined twice in the same project.
even if it is a member of a different class?
for example:
Class one
{
public:
Run();
};
class two
{
public:
Run();
};
main
{
one first;
two second;
first.Run();
second.Run();
}
can i not do this?
EOF
for example:
Class one
{
public:
Run();
};
class two
{
public:
Run();
};
main
{
one first;
two second;
first.Run();
second.Run();
}
can i not do this?
EOF
------------------------------------------VOTE Patrick O'GradyWrite in Presidential CandidateThe Candidate who Cares.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement