[En-Nut-Discussion] compile problem in ethernut 4.x ?
Henrik Maier
hmlists at focus-sw.com
Fri Feb 3 23:29:54 CET 2006
This is a linker error. By removing the function NutDhcpIfConfig(), the
search order for the libraries has changed and the linker cannot resolve
a circular reference any more. (libraries are searched only once by gcc).
I pointed out this weakness recently in several posts and made some
suggestions, as these kind of errors are hard to understand and
diagnose. And the correct order of libraries and how many times they
need to be listed can only be figured out by experimenting.
Change the makefile from:
LIBS = $(LIBDIR)/nutinit.o $(MODS) -lnutpro -lnutos -lnutarch -lnutdev
-lnutnet -lnutfs -lnutcrt
and add -lnutos a second time(!) after -lnutdev:
LIBS = $(LIBDIR)/nutinit.o $(MODS) -lnutpro -lnutos -lnutarch -lnutdev
-lnutnet -lnutos -lnutfs -lnutcrt
Another option is to embed the libraries in start-group/end-group linker
options. gcc will then search the libraries multiple times to resolve
circular references between libraries. For example:
LIBS = $(LIBDIR)/nutinit.o $(MODS) -Wl,--start-group -lnutpro -lnutos
-lnutarch -lnutdev -lnutnet -lnutfs -lnutcrt -Wl,--end-group
Henrik Maier
http://www.proconx.com
def at fea.kiev.ua wrote:
> Hi!
> I try to compile exsamle in ethernut 4.0.1 "httpd" with winavr-20050214
> All compile without problem, but if I make some change:
>
> /*
> * LAN configuration using EEPROM values or DHCP/ARP method.
> * If it fails, use fixed values.
> */
> if (NutDhcpIfConfig("eth0", 0, 60000)) {
> u_char mac[] = { MYMAC };
> u_long ip_addr = inet_addr(MYIP);
> u_long ip_mask = inet_addr(MYMASK);
>
> puts("EEPROM/DHCP/ARP config failed");
> NutNetIfConfig("eth0", mac, ip_addr, ip_mask);
> }
>
> convert to:
>
> /*
> * LAN configuration using EEPROM values or DHCP/ARP method.
> * If it fails, use fixed values.
> */
> // if (NutDhcpIfConfig("eth0", 0, 60000)) {
> u_char mac[] = { MYMAC };
> u_long ip_addr = inet_addr(MYIP);
> u_long ip_mask = inet_addr(MYMASK);
>
> puts("EEPROM/DHCP/ARP config failed");
> NutNetIfConfig("eth0", mac, ip_addr, ip_mask);
> // }
>
> I get that compile error:
>
> c:\Work\ethernut\ethernut-4.0.1\nutapp\httpd>make
> avr-gcc -c -mmcu=atmega128 -Os -fno-delete-null-pointer-checks -Wall
> -Wstrict-pr
> ototypes -Wa,-ahlms=httpserv.lst -DETHERNUT1 -D__HARVARD_ARCH__
> -Ic:/WORK/ethern
> ut/ethernut-4.0.1/nutbld//include
> -Ic:/WORK/ethernut/ethernut-4.0.1/nut//includ
> e httpserv.c -o httpserv.o
> httpserv.c: In function `ShowSockets':
> httpserv.c:341: warning: assignment discards qualifiers from pointer
> target type
>
> httpserv.c:344: warning: assignment discards qualifiers from pointer
> target type
>
> httpserv.c:347: warning: assignment discards qualifiers from pointer
> target type
>
> httpserv.c:350: warning: assignment discards qualifiers from pointer
> target type
>
> httpserv.c:353: warning: assignment discards qualifiers from pointer
> target type
>
> httpserv.c:356: warning: assignment discards qualifiers from pointer
> target type
>
> httpserv.c:359: warning: assignment discards qualifiers from pointer
> target type
>
> httpserv.c:362: warning: assignment discards qualifiers from pointer
> target type
>
> httpserv.c:365: warning: assignment discards qualifiers from pointer
> target type
>
> httpserv.c:368: warning: assignment discards qualifiers from pointer
> target type
>
> httpserv.c:371: warning: assignment discards qualifiers from pointer
> target type
>
> httpserv.c:374: warning: assignment discards qualifiers from pointer
> target type
>
> c:\work\ethernut\ethernut-4.0.1\nut\tools\win32\crurom.exe -r -ourom.c sample
> avr-gcc -c -mmcu=atmega128 -Os -fno-delete-null-pointer-checks -Wall
> -Wstrict-pr
> ototypes -Wa,-ahlms=urom.lst -DETHERNUT1 -D__HARVARD_ARCH__
> -Ic:/WORK/ethernut/e
> thernut-4.0.1/nutbld//include
> -Ic:/WORK/ethernut/ethernut-4.0.1/nut//include u
> rom.c -o urom.o
> avr-gcc httpserv.o urom.o -mmcu=atmega128
> -Wl,--defsym=main=0,-Map=httpserv.map,
> --cref -Lc:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/
> c:/WORK/ethernut/ethernut-4
> .0.1/nutbld/lib//nutinit.o -lnutpro -lnutos -lnutarch -lnutdev -lnutnet
> -lnutfs
> -lnutcrt -o httpserv.elf
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutarch.a(nicrtl.o)(.text+0x348):
> In function `NicInterrupt':
> : undefined reference to `NutEventPostFromIrq'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutarch.a(nicrtl.o)(.text+0x420):
> In function `NicRx':
> : undefined reference to `NutEventWait'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(tcpsock.o)(.text+0x4a2):
> In function `NutTcpSend':
> : undefined reference to `NutEventWait'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(tcpsock.o)(.text+0x5a4):
> In function `NutTcpReceive':
> : undefined reference to `NutEventWait'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(ifconfig.o)(.text+0x2b4)
> : In function `NutNetIfConfig2':
> : undefined reference to `NutEventBroadcast'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(ifconfig.o)(.text+0x2d8)
> : In function `NutNetIfConfig2':
> : undefined reference to `NutEventWait'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(tcpsm.o)(.text+0x318):
> I
> n function `NutTcpStateChange':
> : undefined reference to `NutEventPostAsync'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(tcpsm.o)(.text+0x328):
> I
> n function `NutTcpStateChange':
> : undefined reference to `NutEventBroadcast'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(tcpsm.o)(.text+0x332):
> I
> n function `NutTcpStateChange':
> : undefined reference to `NutEventBroadcast'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(tcpsm.o)(.text+0x33c):
> I
> n function `NutTcpStateChange':
> : undefined reference to `NutEventBroadcast'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(tcpsm.o)(.text+0x37e):
> I
> n function `NutTcpStatePassiveOpenEvent':
> : undefined reference to `NutEventWait'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(tcpsm.o)(.text+0x3ac):
> I
> n function `NutTcpStateActiveOpenEvent':
> : undefined reference to `NutEventWait'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(tcpsm.o)(.text+0x484):
> I
> n function `NutTcpAbortSocket':
> : undefined reference to `NutEventBroadcast'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(tcpsm.o)(.text+0x48c):
> I
> n function `NutTcpAbortSocket':
> : undefined reference to `NutEventBroadcast'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(tcpsm.o)(.text+0x496):
> I
> n function `NutTcpAbortSocket':
> : undefined reference to `NutEventBroadcast'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(tcpsm.o)(.text+0x4a0):
> I
> n function `NutTcpAbortSocket':
> : undefined reference to `NutEventBroadcast'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(tcpsm.o)(.text+0x760):
> I
> n function `NutTcpSm':
> : undefined reference to `NutEventWait'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(tcpsm.o)(.text+0xbbe):
> I
> n function `NutTcpSm':
> : undefined reference to `NutEventPost'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(tcpsm.o)(.text+0xc5c):
> I
> n function `NutTcpSm':
> : undefined reference to `NutEventBroadcast'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(tcpsm.o)(.text+0xd1c):
> I
> n function `NutTcpSm':
> : undefined reference to `NutEventPost'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(tcpsm.o)(.text+0xe34):
> I
> n function `NutTcpSm':
> : undefined reference to `NutEventPost'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(tcpsm.o)(.text+0xe40):
> I
> n function `NutTcpSm':
> : undefined reference to `NutEventPost'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(tcpsm.o)(.text+0xea8):
> I
> n function `NutTcpSm':
> : undefined reference to `NutEventPost'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(tcpsm.o)(.text+0xf40):
> I
> n function `NutTcpSm':
> : undefined reference to `NutEventPost'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(tcpsm.o)(.text+0x1142):
> more undefined references to `NutEventPost' follow
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(arpcache.o)(.text+0x22):
> In function `ArpCacheFlush':
> : undefined reference to `NutEventBroadcastAsync'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(arpcache.o)(.text+0x218)
> : In function `NutArpCacheUpdate':
> : undefined reference to `NutEventBroadcast'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(arpcache.o)(.text+0x33c)
> : In function `NutArpCacheQuery':
> : undefined reference to `NutEventWait'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(udpin.o)(.text+0xd8):
> In
> function `NutUdpInput':
> : undefined reference to `NutEventPost'
> c:/WORK/ethernut/ethernut-4.0.1/nutbld/lib/\libnutnet.a(udpsock.o)(.text+0x150):
> In function `NutUdpReceiveFrom':
> : undefined reference to `NutEventWait'
> make: *** [httpserv.elf] Error 1
>
> c:\Work\ethernut\ethernut-4.0.1\nutapp\httpd>
>
> Ethernut was compiled with ethernut13g.conf
>
> P/S
> Same problem I get in 4.1.3 8(
>
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
>
>
>
More information about the En-Nut-Discussion
mailing list