[En-Nut-Discussion] Problem compiling httpd demo

Harald Kipp harald.kipp at egnite.de
Thu Feb 23 19:07:42 CET 2006


Searching Google groups for "undefined reference NutEventBroadcast"

shows

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 




More information about the En-Nut-Discussion mailing list