[Help me] A link error

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
SCSoft
Posts: 11
Joined: Tue Jan 31, 2006 12:00 am

[Help me] A link error

Post by SCSoft »

ld give me a error message like this:
undefined reference to _functionname

in console:
ld -Ttext 0x10500 --oformat binary -o main.bin main.o timer.o task.o

timer.o:timer.c:(.text+0xc6): undefined reference to '_install'


in timer.c:
extern void install(void);

...
...
install();
Last edited by SCSoft on Sun Feb 05, 2006 12:00 am, edited 1 time in total.
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

Re: [Help me] A link error

Post by carbonBased »

You haven't told us where _install is defined. Is it being linked in?

Which platform/object format are you using? Certain ABIs do not prepend underscores, while others do.

--Jeff
SCSoft
Posts: 11
Joined: Tue Jan 31, 2006 12:00 am

Re: [Help me] A link error

Post by SCSoft »

_install is defined in a asm file :
[bits 32]

[global _install]
_install:
......


platform/object format? What's that?
User avatar
intel_breaker
Member
Member
Posts: 46
Joined: Tue Jan 04, 2005 12:00 am
Location: Poland
Contact:

Re: [Help me] A link error

Post by intel_breaker »

Platfrom: Windows/Linux/BSD, or anything else=)
Object format: elf, coff ?
Maybe you don't have to use underscore before function name, check it!
SCSoft
Posts: 11
Joined: Tue Jan 31, 2006 12:00 am

Re: [Help me] A link error

Post by SCSoft »

It's Ok after I add "section .text" to the asm file!

^^thanks all the same
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

Re: [Help me] A link error

Post by carbonBased »

Hopefully you understand *why*?

Most programmers tend to know what platform they're developing on! Keep in mind that other ABIs (Linux/ELF) will not use underscores and you'll get the same link error.

--Jeff
SCSoft
Posts: 11
Joined: Tue Jan 31, 2006 12:00 am

Re: [Help me] A link error

Post by SCSoft »

I think that the gcc will take the function to .text section but nasm won't.

where can I find the infomation for gcc and ld
Last edited by SCSoft on Sun Feb 12, 2006 12:00 am, edited 1 time in total.
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

Re: [Help me] A link error

Post by carbonBased »

You should be able to find information about it all over the internet. If you've got specific things you want to look into, google's probably your best resource. gcc.gnu.org probably contains a lot of information, as well.

ld is part of the binutils distribution, and has a homesite at http://www.gnu.org/software/binutils/

--Jeff
Post Reply