When I try to build my project in Visual c++ it comes up with this:
1>Game.obj : error LNK2005: "bool gameend" (?gameend@@3_NA) already defined in DisplayGrid.obj
repeated 226 times with different variables
I have looked up on google how to fix it but I do not understand most of them as I am quite new to programming. If anyone could tell me how to fix this in a way that someone quite new to programming would understand.
Error LNK2005
Moderator: Coders of Rage
- thejahooli
- Chaos Rift Junior
- Posts: 265
- Joined: Fri Feb 20, 2009 7:45 pm
- Location: London, England
Error LNK2005
I'll make your software hardware.
- Spikey
- Chaos Rift Cool Newbie
- Posts: 98
- Joined: Sat Dec 13, 2008 6:39 am
- Programming Language of Choice: C++
- Location: Ottawa, Canada
- Contact:
Re: Error LNK2005
Welcome to linker hell!
Says your defining something that already exists. The easy way is to add #pragma to the first line in all your headers. Or you can wrap your headers like this for non-window machines:
If that doesn't help, then you might have to check your #includes, make sure they're executed in the right order.
Basically the pre-processors ( keywords with # ) will make sure headers are only defined once.
Hope it works, showing code helps diagnose problems alot more too.
Says your defining something that already exists. The easy way is to add #pragma to the first line in all your headers. Or you can wrap your headers like this for non-window machines:
Code: Select all
#ifndef _SOMETHING_UNIQUE_
#define _SOMETIHNG_UNIQUE_
(code)
#endif
Basically the pre-processors ( keywords with # ) will make sure headers are only defined once.
Hope it works, showing code helps diagnose problems alot more too.
Re: Error LNK2005
If you're only going to use VC++ then you can also try a single line of code that would be equivalent to the above #ifndef wrapper guards:
Code: Select all
#pragma once