Reputation: 1
I am writing a program using the Contiki operating system.
I have the remote_firmware.c
file and a folder called parser with the files parser.h
and parser.c
where I wrote the method void test()
. I included parser.h
in remote_firmware.c
with:
#include "parser/parser.h"
The Makefile looks like this:
CONTIKI_PROJECT = remote_firmware
all: $(CONTIKI_PROJECT)
#UIP_CONF_IPV6=1
CONTIKI_WITH_RIME = 1
CONTIKI = $(HOME)/contiki
include $(CONTIKI)/Makefile.include
When I try to build this the Error occurs:
undefined reference to 'test'
I am aware that the Makefile needs to know about parser.h
, but I do not know how. I tried several solutions which were proposed here but I guess I did something wrong. Maybe somebody of you know what to do?
Thank you a lot.
Upvotes: 0
Views: 1306
Reputation: 1025
Where is your source file located? Try adding the source file name to the PROJECT_SOURCEFILES
preprocessor variable (i.e PROJECT_SOURCEFILES+=parser.c
) and adding the location of the source file to the CONTIKIDIRS
preprocessor variable (i.e CONTIKIDIRS+={Directory}
).
If parser.c depends on a lot other C files you might want create an C library archive first and then adding the library to your project by adding the name of the library to the TARGET_LIBFILES
variable.
Upvotes: 2
Reputation: 3688
The error undefined reference to test
is an error from the linker not the compiler. It has nothing to do with including a header file. It means when you linked the executable you didn't include parser.o
Upvotes: 1