Go to Post Look at FIRST 7 years ago. Look at FIRST now. Thanks Bill. - Steven Donow [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 01-04-2004, 13:37
wun's Avatar
wun wun is offline
Registered User
AKA: David Wolever
#0865 (Warp7)
Team Role: Programmer
 
Join Date: Dec 2003
Rookie Year: 2001
Location: Toronto
Posts: 84
wun will become famous soon enough
Send a message via AIM to wun Send a message via MSN to wun
multiple definition error in MCC/Linker (possible bug?)

Hey,
I have just been working on my code, when all of a sudden I started getting multiple definition errors from the linker on a variable named drive_mode.
I searched through all the files involved (grep drive_mode {*.c,*.h}), and found only one definition.
I have also deleted all the object files, then re-compiled from scratch and changed the variables name.
I think this is a bug with MCC or the linker because it started out being one variable, and now it is this one.
Sorry I cant give any compiler output, but I am at a regional, and can not move the computer with the code on it.
If anyone really wants, I could get it tonight (when I go home thou).
I have asked a couple of the programmers here, and they cant figure out what the problem is either.
Thanks a lot!
__________________
Help Microsoft stop piracy. Use Linux!

I have three gmail invitations, message me if you want one
  #2   Spotlight this post!  
Unread 01-04-2004, 13:58
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: multiple definition error in MCC/Linker (possible bug?)

Quote:
Originally Posted by wun
I have just been working on my code, when all of a sudden I started getting multiple definition errors from the linker on a variable named drive_mode.
I searched through all the files involved (grep drive_mode {*.c,*.h}), and found only one definition.
That symptom points to one of two things. Either you have more than one #include for the same .h file (and you're not "protecting" it with #ifdef), or you have added the same .c file to the project twice. The first problem would show up in the code. The second problem would not. Try looking at the project window and make sure you only have each file in there once. If something is duplicated, remove the extra one.
  #3   Spotlight this post!  
Unread 01-04-2004, 14:31
wun's Avatar
wun wun is offline
Registered User
AKA: David Wolever
#0865 (Warp7)
Team Role: Programmer
 
Join Date: Dec 2003
Rookie Year: 2001
Location: Toronto
Posts: 84
wun will become famous soon enough
Send a message via AIM to wun Send a message via MSN to wun
Re: multiple definition error in MCC/Linker (possible bug?)

Quote:
Originally Posted by Alan Anderson
That symptom points to one of two things. Either you have more than one #include for the same .h file (and you're not "protecting" it with #ifdef)
I havent added any #include statements, so I dont think it would be that

Quote:
Originally Posted by Alan Anderson
or you have added the same .c file to the project twice. The first problem would show up in the code. The second problem would not. Try looking at the project window and make sure you only have each file in there once. If something is duplicated, remove the extra one.
I am not using the MLAB IDE (vim + make), so I do not think that would be an issue. I get the same problem when I do load it in to the IDE thou.

I have also tryed to build it on 4 different macines, so it is not my computer that is the problem either.
Thanks for the quick reply thou.
__________________
Help Microsoft stop piracy. Use Linux!

I have three gmail invitations, message me if you want one
  #4   Spotlight this post!  
Unread 01-04-2004, 15:05
KenWittlief KenWittlief is offline
.
no team
Team Role: Engineer
 
Join Date: Mar 2003
Location: Rochester, NY
Posts: 4,213
KenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond repute
Re: multiple definition error in MCC/Linker (possible bug?)

I dont know if this helps, but I searched the default code and drive_mode is not in the map file - so if its in your code you must have added it

the obvious thing to do is comment it out where you know it is (where you want it to be) and see if it compiles

if it does then search the .lst file and see where the other one is or check the map file and see if its in there - if its in the map file then its getting declared somewhere

could it be in the file with all the constants? did you declare it as a constant once and foget?
  #5   Spotlight this post!  
Unread 01-04-2004, 15:39
Greg Ross's Avatar
Greg Ross Greg Ross is offline
Grammar Curmudgeon
AKA: gwross
FRC #0330 (Beach 'Bots)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 2,245
Greg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond repute
Send a message via AIM to Greg Ross Send a message via Yahoo to Greg Ross
Re: multiple definition error in MCC/Linker (possible bug?)

Where did the grep find it? Was it in a .h file? What does the definition look like?

What you should have is something like
Code:
int drive_mode;
in ONE .c file. And (assuming you really need to reference the variable in another program) in your .h file, put
Code:
extern int drive_mode;
If you have the
Code:
int drive_mode;
(without the extern keyword) in a .h file, and #include it in multiple files, you will get a multiple definition error.
__________________
Greg Ross (The Grammar Curmudgeon formerly known as gwross)
S/W Engineer, Team 330, the Beach 'Bots
<--The Grammar Curmudgeon loves this cartoon.
“Life should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!" Hunter S. Thompson
"Playing a practical joke means doing something mean and calling it funny." Me
  #6   Spotlight this post!  
Unread 01-04-2004, 17:49
wun's Avatar
wun wun is offline
Registered User
AKA: David Wolever
#0865 (Warp7)
Team Role: Programmer
 
Join Date: Dec 2003
Rookie Year: 2001
Location: Toronto
Posts: 84
wun will become famous soon enough
Send a message via AIM to wun Send a message via MSN to wun
Re: multiple definition error in MCC/Linker (possible bug?)

Hey,
Thanks for all the help.
I finally figured out what it was.
When I defined variables in the .h file, it tryed to use them in all the .c files. This, of corse, lead to conflicts.
This could have been fixed by using the extern statement (#extern int drive_mode), or by doing what I did - just putting them in the .c files where they are needed.
I finaly figured this out after and hour or so of looking over/commenting stuff in and out with one of our mentors who works with C.
__________________
Help Microsoft stop piracy. Use Linux!

I have three gmail invitations, message me if you want one
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 17:57.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi