# Solved: Visual C error: error LNK2005: already defined



## someuser77 (Jun 26, 2005)

hello, i am using Microsoft Visual C++ 6.0 Standard Edition.
i made a new project and added my files to it, i have 3 .c files:
2 of them are files with functions, and another one that calls the other two.
when i compile (Ctrl+F7) the file i dont get any errors but when i build (F7) the project i get LNK2005 error:


> error LNK2005: _drawMySquare already defined in DRAWOBJ.OBJ


drawMySquare if a function included in DRAWOBJ.C
under Code Generation i use Multithreaded DLL/Debug Multithreaded DLL
i use:

```
#include "DRAWOBJ.C"
```
 to add the .c file.


----------



## GCDude (Apr 1, 2005)

ok this isnt how u should be setting up your project really. as you have it now the linker is going thru drawobj.c twice, hence the error. You can resolve this in a number of ways depending on how u have your project setup (recreate project correctly/in c++/use #if !defined), post a little example with the 3 files that still produces this error, and ill give u an idea of what you should really be doing. hopefully


----------



## someuser77 (Jun 26, 2005)

i made a drawobj.h file with the functions titles from drawobj.c, included only the .h file and it looks okay. 
thanks GCDude!


----------



## AGCurry (Jun 15, 2005)

Yes. Executable code should not #included; rather, it should be linked.


----------



## someuser77 (Jun 26, 2005)

i guess i can mark this thread as solved, right?


----------



## GCDude (Apr 1, 2005)

yep


----------

