There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen boot bsod computer connection crash css dell display drive driver drivers email error ethernet excel explorer firefox firefox 3 game hard drive internet internet explorer itunes laptop lcd malware monitor network networking outlook outlook 2003 outlook express partition password printer problem problems ram router slow sound trojan usb virus vista windows windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Solved: Visual C error: error LNK2005: already defined


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
someuser77's Avatar
Junior Member with 6 posts.
 
Join Date: Jun 2005
Experience: Beginner
26-Jun-2005, 11:52 AM #1
Solved: Visual C error: error LNK2005: already defined
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:
Quote:
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.
GCDude's Avatar
Senior Member with 400 posts.
 
Join Date: Apr 2005
Location: Brighton, UK
Experience: Possibly Competent
29-Jun-2005, 06:36 AM #2
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's Avatar
Junior Member with 6 posts.
 
Join Date: Jun 2005
Experience: Beginner
29-Jun-2005, 06:48 AM #3
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's Avatar
Senior Member with 431 posts.
 
Join Date: Jun 2005
Location: Kansas City area
Experience: advanced but learning
29-Jun-2005, 10:12 AM #4
Yes. Executable code should not #included; rather, it should be linked.
someuser77's Avatar
Junior Member with 6 posts.
 
Join Date: Jun 2005
Experience: Beginner
30-Jun-2005, 07:35 AM #5
i guess i can mark this thread as solved, right?
GCDude's Avatar
Senior Member with 400 posts.
 
Join Date: Apr 2005
Location: Brighton, UK
Experience: Possibly Competent
01-Jul-2005, 12:13 PM #6
yep
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 01:52 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.