I've been programming in SES for several months now, and I need to put the code into libraries to keep an overview of my project.
I've been able to include SDK libraries by following the tutorials and the help of this forum.
But I haven't figured out how to create custom libraries.
As a starting point, I opened the blinky example in ./nRF5_SDK_16.0.0_98a08e2/examples/peripheral/blinky
My main.c file:
#include "nrf_delay.h" // needed for nrf_delay_ms #include "mylib.h" int main(void) { while (true) { nrf_delay_ms(500); int a = function1(); printf("a = %i\n",a); } }
My mylib.c:
#include "mylib.h" int myfunction1() { return 10; }
My mylib.h:
#ifndef MYLIB_H #define MYLIB_H int myfunction1(); #endif
The error message I get is: undefined reference to function1
I have done the following steps as in the tutorial:
1) create subdirectory include
2) place mylib.c and mylib.h into the subdirectory include
3) add the subdirectory in Options - Common - Preprocessor - User Include Directories
4) Under Application add mylib.c file
I have done the following verification steps:
1) File - Open file from Solution -> confirmed my library files are listed and part of the project
2) mylib.c -> Output Files -> mylib.o -> object file is created by compiler
Somehow the object file is not linked to the compiler. What am I doing wrong?
/ephimee