Page 1 of 1

[Help me] A link error

Posted: Sun Feb 05, 2006 12:00 am
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();

Re: [Help me] A link error

Posted: Mon Feb 06, 2006 12:00 am
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

Re: [Help me] A link error

Posted: Mon Feb 06, 2006 12:00 am
by SCSoft
_install is defined in a asm file :
[bits 32]

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


platform/object format? What's that?

Re: [Help me] A link error

Posted: Mon Feb 06, 2006 12:00 am
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!

Re: [Help me] A link error

Posted: Tue Feb 07, 2006 12:00 am
by SCSoft
It's Ok after I add "section .text" to the asm file!

^^thanks all the same

Re: [Help me] A link error

Posted: Tue Feb 07, 2006 12:00 am
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

Re: [Help me] A link error

Posted: Sun Feb 12, 2006 12:00 am
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

Re: [Help me] A link error

Posted: Mon Feb 13, 2006 12:00 am
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