How come...

Started by
11 comments, last by deadlydog 21 years, 1 month ago
This is the exact error I get:

Linking...
Connex.obj : error LNK2005: "public: __thiscall CBlock::CBlock(int,int,int,int,int,int,int,int)" (??0CBlock@@QAE@HHHHHHHH@Z) already defined in CBlock.obj
Connex.obj : error LNK2005: "public: __thiscall CBlock::~CBlock(void)" (??1CBlock@@QAE@XZ) already defined in CBlock.obj
Connex.obj : error LNK2005: "public: void __thiscall CBlock::ChangeBlockType(int)" (?ChangeBlockType@CBlock@@QAEXH@Z) already defined in CBlock.obj
Connex.obj : error LNK2005: "public: bool __thiscall CBlock::RotateBlockClockwise(void)" (?RotateBlockClockwise@CBlock@@QAE_NXZ) already defined in CBlock.obj
Connex.obj : error LNK2005: "public: bool __thiscall CBlock::RotateBlockCounterClockwise(void)" (?RotateBlockCounterClockwise@CBlock@@QAE_NXZ) already defined in CBlock.obj
Connex.obj : error LNK2005: "public: bool __thiscall CBlock::MoveBlockLeft(void)" (?MoveBlockLeft@CBlock@@QAE_NXZ) already defined in CBlock.obj
Connex.obj : error LNK2005: "public: bool __thiscall CBlock::MoveBlockRight(void)" (?MoveBlockRight@CBlock@@QAE_NXZ) already defined in CBlock.obj
Connex.obj : error LNK2005: "public: bool __thiscall CBlock::MoveBlockDown(void)" (?MoveBlockDown@CBlock@@QAE_NXZ) already defined in CBlock.obj
Connex.obj : error LNK2005: "public: bool __thiscall CBlock::MoveBlockUp(void)" (?MoveBlockUp@CBlock@@QAE_NXZ) already defined in CBlock.obj
Connex.obj : error LNK2005: "public: bool __thiscall CBlock::MoveEntireBlockToCell(int,int)" (?MoveEntireBlockToCell@CBlock@@QAE_NHH@Z) already defined in CBlock.obj
Connex.obj : error LNK2005: "public: int __thiscall CBlock::ReturnBlockCellRow(void)const " (?ReturnBlockCellRow@CBlock@@QBEHXZ) already defined in CBlock.obj
Connex.obj : error LNK2005: "public: int __thiscall CBlock::ReturnBlockCellColumn(void)const " (?ReturnBlockCellColumn@CBlock@@QBEHXZ) already defined in CBlock.obj
Connex.obj : error LNK2005: "public: int __thiscall CBlock::ReturnBlockStartingCellRow(void)const " (?ReturnBlockStartingCellRow@CBlock@@QBEHXZ) already defined in CBlock.obj
Connex.obj : error LNK2005: "public: int __thiscall CBlock::ReturnBlockStartingCellColumn(void)const " (?ReturnBlockStartingCellColumn@CBlock@@QBEHXZ) already defined in CBlock.obj
Connex.obj : error LNK2005: "public: bool __thiscall CBlock::IsEntireBlockMoveValid(struct sBlock &)const " (?IsEntireBlockMoveValid@CBlock@@QBE_NAAUsBlock@@@Z) already defined in CBlock.obj
Connex.obj : error LNK2005: "public: void __thiscall CBlock:laceEntireBlockOnBoard(int)" (?PlaceEntireBlockOnBoard@CBlock@@QAEXH@Z) already defined in CBlock.obj
Connex.obj : error LNK2005: "public: void __thiscall CBlock::EraseEntireBlockFromBoard(void)" (?EraseEntireBlockFromBoard@CBlock@@QAEXXZ) already defined in CBlock.obj
Connex.obj : error LNK2005: "public: bool __thiscall CBlock::SetBlockCellRow(int)" (?SetBlockCellRow@CBlock@@QAE_NH@Z) already defined in CBlock.obj
Connex.obj : error LNK2005: "public: bool __thiscall CBlock::SetBlockCellColumn(int)" (?SetBlockCellColumn@CBlock@@QAE_NH@Z) already defined in CBlock.obj
Connex.obj : error LNK2005: "public: bool __thiscall CBlock::SetBlockCellStartRow(int)" (?SetBlockCellStartRow@CBlock@@QAE_NH@Z) already defined in CBlock.obj
Connex.obj : error LNK2005: "public: bool __thiscall CBlock::SetBlockCellStartColumn(int)" (?SetBlockCellStartColumn@CBlock@@QAE_NH@Z) already defined in CBlock.obj
Connex.obj : error LNK2005: "public: void __thiscall CBlock::DrawAllBlocks(void)" (?DrawAllBlocks@CBlock@@QAEXXZ) already defined in CBlock.obj
Connex.obj : error LNK2005: "private: void __thiscall CBlock::LoadBlocksIntoBlockData(void)" (?LoadBlocksIntoBlockData@CBlock@@AAEXXZ) already defined in CBlock.obj
Debug/Connex.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.


- Dan
He who laughs, lasts
-Dan- Can't never could do anything | DansKingdom.com | Dynamic Particle System Framework for XNA
Advertisement
Don''t put the CBlock.cpp file in the CBlock.h file

Insert the CBlock.cpp file put it into your project. The file will compile into an object file which will then be linked with whatever other .cpp files are using the CBlock.h file. They will find the functions defined just once in the CBlock.obj file.

Okay?
Thnx for all the replies everyone. The problem was just that I was using the ifndef and define''s in my .cpp as well as my .h''s. Once I took them out of my .cpp file, everything worked fine without the include .cpp in the .h. So winner was Neophyte. Thnx for the solution, and thanks for all the other suggestions from everyone else.

- Dan
He who laughs, lasts
-Dan- Can't never could do anything | DansKingdom.com | Dynamic Particle System Framework for XNA

This topic is closed to new replies.

Advertisement