LD linker claiming multiple definitions of functions

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
cg123

LD linker claiming multiple definitions of functions

Post 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. :P
bluecode

Re:LD linker claiming multiple definitions of functions

Post by bluecode »

cg123 wrote:I'm guessing it's something incredibly stupid I did.. seems most likely. :P
;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).
cg123

Re:LD linker claiming multiple definitions of functions

Post by cg123 »

Ok.. I'll try that, thanks. :D
cg123

Re:LD linker claiming multiple definitions of functions

Post by cg123 »

Yep.. that was the problem. Thanks. ;D
cg123

Re:LD linker claiming multiple definitions of functions

Post by cg123 »

Nope... still doing it, actually... didn't scroll up far enough. :/
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:LD linker claiming multiple definitions of functions

Post 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
Every good solution is obvious once you've found it.
cg123

Re:LD linker claiming multiple definitions of functions

Post by cg123 »

Oh.. I'll try that now, thanks.
cg123

Re:LD linker claiming multiple definitions of functions

Post 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
Post Reply