Hello, I have linking problem in my project. Nonetheless I defined correctly my include paths, linker is printing message L6218E: Undefined symbol nchecksum_of (referred from epa_protocol.o). In file epa_protocol.c are included all files, including checksum.h. I have no idea what's goin wrong.
Do you have idea how to solve the problem?
This is declaration of function in header checksum.h
/* * checksum.h * * Created on: Mar 18, 2016 * Author: nenad */ #ifndef NEON_LIB_INCLUDE_LIB_CHECKSUM_H_ #define NEON_LIB_INCLUDE_LIB_CHECKSUM_H_ #include <stddef.h> #include <stdint.h> uint8_t nchecksum_of(const void * data, size_t size); #endif /* NEON_LIB_INCLUDE_LIB_CHECKSUM_H_ */
this file's called in appropriate .c file like this
#include "lib/checksum.h" uint8_t nchecksum_of(const void * data, size_t size) { unsigned int checksum_; unsigned int idx; const uint8_t * data_ = data; for (checksum_ = 0, idx = 0; idx < size; idx++) { checksum_ += *data_++; } return (-(uint8_t)checksum_); }
here is declaration part of epa_protocol.c
#include "lib/bits.h" #include "lib/checksum.h" #include "port/compiler.h" #include "usbd_cdc_if.h" #include "ppbuff.h"
The use of #include is to make sure the compilation step have all required information.
But you are getting a linker error - so you are already one step further.
Does your project contain all used *.c files, so the compiler will compile all required source files and so the linker will bring in all the produced object files?
It isn't enough to make use of a "file.h" that names a function. The project must compile and link the actual "file.c" that happens to contain the implementation.
I've got in mind this information. I haven't added an appropriate file to one of existing source groups in the project. Because of that, an error has generated. After adding the file compilation succeed. Thanks for an answer.