Solved: Visual C error: error LNK2005: already defined

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

someuser77

Thread Starter
Joined
Jun 26, 2005
Messages
6
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:
Code:
#include "DRAWOBJ.C"
to add the .c file.
 
Joined
Apr 1, 2005
Messages
394
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

Thread Starter
Joined
Jun 26, 2005
Messages
6
i made a drawobj.h file with the functions titles from drawobj.c, included only the .h file and it looks okay.
thanks GCDude! :)
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top