Page 1 of 1
LD linker claiming multiple definitions of functions
Posted: Mon Aug 07, 2006 9:08 pm
by cg123
I'm not quite sure what to do here.. whenever I try to compile my OS with my linker script it claims every function is defined multiple times. I have all of them defined in 3 .h files.
Here's my source code:
http://www.megaupload.com/?d=BF2KKBSB
(lot of files)
Here's the log from the command prompt:
http://charlesgranville.awardspace.com/cmdpromptlog.txt
Anyone have any ideas why it does that?
I'm guessing it's something incredibly stupid I did.. seems most likely.
Re:LD linker claiming multiple definitions of functions
Posted: Mon Aug 07, 2006 9:21 pm
by bluecode
cg123 wrote:I'm guessing it's something incredibly stupid I did.. seems most likely.
;D
You should not define your functions in header files, but just declare them
That's most likely the reason for these linker errors (I haven't looked at your code).
Re:LD linker claiming multiple definitions of functions
Posted: Mon Aug 07, 2006 9:31 pm
by cg123
Ok.. I'll try that, thanks.
Re:LD linker claiming multiple definitions of functions
Posted: Mon Aug 07, 2006 9:41 pm
by cg123
Yep.. that was the problem. Thanks. ;D
Re:LD linker claiming multiple definitions of functions
Posted: Mon Aug 07, 2006 9:48 pm
by cg123
Nope... still doing it, actually... didn't scroll up far enough. :/
Re:LD linker claiming multiple definitions of functions
Posted: Mon Aug 07, 2006 10:45 pm
by Solar
Do you have include guards against multiple inclusions?
file myheader1.h:
Code: Select all
#ifndef _MYHEADER1_H
#define _MYHEADER1_H
/* Your code here */
#endif
file myheader2.h:
Code: Select all
#ifndef _MYHEADER2_H
#define _MYHEADER2_H
/* Your code here */
#endif
Re:LD linker claiming multiple definitions of functions
Posted: Mon Aug 07, 2006 10:54 pm
by cg123
Oh.. I'll try that now, thanks.
Re:LD linker claiming multiple definitions of functions
Posted: Mon Aug 07, 2006 11:01 pm
by cg123
Ok, I found the problem.. I didn't need to add the filenames to the command for the linker, I had already specified them in the linker script.. so it was linking everything twice. xD
Thanks for all the help. ;D