[En-Nut-Discussion] Ethernut 3 linking problem: multiple definitions and undefined references
José Vallet
jose.vallet at hut.fi
Tue Feb 17 12:48:32 CET 2009
Hello.
We are porting an existing application from Ethernut2 to Ethernut3 (with
ethernut-4.4.0), and we are stuck with some linkings problems. The
problems appear _only_ when we link the code for the ARM architecture,
whereas for AVR everything goes smoothly.
They problems are:
* PROBLEM 1: multiple definitions of `_close', `_write', `_read' and
`_open'.
The type of messages that we get from the linker are, for example, like
this, (shrinked for easier reading. The complete output follows at the
end of the message)
__________________
/usr/arm-elf/lib/libc.a(syscalls.o): In function `_close':
../../../../.././newlib/libc/sys/arm/syscalls.c:432: multiple definition
of `_close'
/home/jose/ethernut/ethernut-4.4.0-bld/lib/libnutcrt.a(close.o):close.c:(.text+0x0):
first defined here
/usr/arm-elf/bin/ld: Warning: size of symbol `_close' changed from 60 in
/home/jose/ethernut/ethernut-4.4.0-bld/lib/libnutcrt.a(close.o) to 16 in
/usr/arm-elf/lib/libc.a(syscalls.o)
__________________
To my poor understanding it looks something like the linker has found 2
different `_close' functions, one from NutOS at libnutcrt.a and the
other from newlib at libc.a, and does not know which one to use.
I have read
http://groups.google.com/group/osdeve_mirror_rtos_En-Nut-Discussion/browse_thread/thread/b6213c340dce6887?q=libnutcrt+multiple+definitions#07e22d1f0be9c758
which seems to be a similar problem, but I have still clouds in my mind.
In the previous thread the use of the strdup() function triggered the
linker problems, and it seems that the solution was to add an
implementation of strdup() to the aplication code. In our case I don't
know what function/s might be triggering the linker complaints, so I
don't know what to include in our application code. And still I am not
sure that this is what I should really do. Any hints are welcomed.
* PROBLEM 2: undefined reference to `NutTraceTerminal'
About the undefined reference to `NutTraceTerminal' the linker message is
__________________
../NutDAC/lib/libndterm.a(nut-cmds-term.o): In function
`nut_cmds_register_cmds':
nut-cmds-term.c:(.text+0x30): undefined reference to `NutTraceTerminal'
__________________
do I have to do something special in Ethernut3 in order to use the trace
utilities?
* PROBLEM 3: undefined reference to `end'
The message from the linker is
__________________
/usr/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/libc.a(syscalls.o):
In function `_sbrk':
syscalls.c:(.text+0xdc): undefined reference to `end'
__________________
this one left me even more puzzled.
Any hints are warmly welcomed.
Regards
José
Here I include the full linker output
______________
arm-elf-gcc PemCtrl_v2.o adc.o boardtemp.o dac.o expander.o hal.o
ctrl_daemon.o -mcpu=arm7tdmi -nostartfiles
-T/home/jose/ethernut/ethernut-4.4.0/arch/arm/ldscripts/at91_ram.ld
-Wl,-Map=PemCtrl_v2.map,--cref,--no-warn-mismatch
-L/home/jose/ethernut/ethernut-4.4.0-bld/lib -L../NutDAC/lib
-Wl,--start-group /home/jose/ethernut/ethernut-4.4.0-bld/lib/nutinit.o
-lnutpro -lnutfs -lnutarch -lnutnet -lnutos -lnutdev -lnutarch -lnutcrt
-lm -lndchal -lndsl -lndterm -lndnet -lspi -Wl,--end-group -o
PemCtrl_v2.elf
/usr/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/libc.a(syscalls.o):
In function `_close':
../../../../.././newlib/libc/sys/arm/syscalls.c:432: multiple definition
of `_close'
/home/jose/ethernut/ethernut-4.4.0-bld/lib/libnutcrt.a(close.o):close.c:(.text+0x0):
first defined here
/usr/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld: Warning:
size of symbol `_close' changed from 60 in
/home/jose/ethernut/ethernut-4.4.0-bld/lib/libnutcrt.a(close.o) to 16 in
/usr/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/libc.a(syscalls.o)
/usr/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/libc.a(syscalls.o):
In function `_write':
../../../../.././newlib/libc/sys/arm/syscalls.c:333: multiple definition
of `_write'
/home/jose/ethernut/ethernut-4.4.0-bld/lib/libnutcrt.a(write.o):write.c:(.text+0x0):
first defined here
/usr/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld: Warning:
size of symbol `_write' changed from 52 in
/home/jose/ethernut/ethernut-4.4.0-bld/lib/libnutcrt.a(write.o) to 112
in
/usr/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/libc.a(syscalls.o)
/usr/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/libc.a(syscalls.o):
In function `_read':
../../../../.././newlib/libc/sys/arm/syscalls.c:228: multiple definition
of `_read'
/home/jose/ethernut/ethernut-4.4.0-bld/lib/libnutcrt.a(read.o):read.c:(.text+0x0):
first defined here
/usr/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld: Warning:
size of symbol `_read' changed from 52 in
/home/jose/ethernut/ethernut-4.4.0-bld/lib/libnutcrt.a(read.o) to 104 in
/usr/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/libc.a(syscalls.o)
/usr/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/libc.a(syscalls.o):
In function `_open':
../../../../.././newlib/libc/sys/arm/syscalls.c:410: multiple definition
of `_open'
/home/jose/ethernut/ethernut-4.4.0-bld/lib/libnutcrt.a(open.o):open.c:(.text+0x0):
first defined here
/usr/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/bin/ld: Warning:
size of symbol `_open' changed from 172 in
/home/jose/ethernut/ethernut-4.4.0-bld/lib/libnutcrt.a(open.o) to 32 in
/usr/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/libc.a(syscalls.o)
../NutDAC/lib/libndterm.a(nut-cmds-term.o): In function
`nut_cmds_register_cmds':
nut-cmds-term.c:(.text+0x30): undefined reference to `NutTraceTerminal'
/usr/bin/../lib/gcc/arm-elf/4.1.1/../../../../arm-elf/lib/libc.a(syscalls.o):
In function `_sbrk':
syscalls.c:(.text+0xdc): undefined reference to `end'
collect2: ld returned 1 exit status
make[1]: *** [PemCtrl_v2.elf] Error 1
More information about the En-Nut-Discussion
mailing list