I have included math.h
in 1.c
and LDLIBS=-lm
in the makefile
.
1.c and 2.c are some of the files in current directory.
Make file is as follows:
dINES+=PROJECT_CONF_H=\"project-conf.h\"
CONTIKI_PROJECT = 1 2
all: $(CONTIKI_PROJECT)
CONTIKI = ../..
WITH_UIP6=1
UIP_CONF_IPV6=1
CFLAGS+= -DUIP_CONF_IPV6_RPL -DUIP_CONF_IPV6 -DWITH_UIP6
LDLIBS=-lm
ifdef PERIOD
CFLAGS=-DPERIOD=$(PERIOD)
endif
include $(CONTIKI)/Makefile.include
I have read related stackoverflow question and answers but unable to understand why Undefined reference to sqrt
.
First, notice that include $(CONTIKI)/Makefile.include
could unset any settings you have made above. So we cannot debug your problem.
Then, run make -p
once to understand the builtin rules (assuming you are using GNU make). Be sure to read documentation of make
. Run also make --trace
and/or use remake (e.g. as remake -x
) to debug your Makefile
.
Be aware that the order of program arguments to gcc
matters a lot. Read first the Invoking GCC chapter of the documentation of gcc
. You want to compile with -Wall -g
(to get all warnings & debug info) which might be added to your CFLAGS+=
line. Perhaps your
CFLAGS=-DPERIOD=$(PERIOD)
line should be CFLAGS+= -DPERIOD=$(PERIOD)
Perhaps your LDLIBS=-lm
line should be LIBES= -lm
.
The Undefined reference: sqrt
message might be because your compilation command (run by make
) has -lm
missing or in the wrong order.