I want to add some third party libraries to Contiki, but at the moment I can't. So I wanted to just test with a simple library.
I wrote two files hello.c hello.h, in hello.c I have:
printf(" Hello everbody, library call\n");
In hello.h I have:
extern void print_hello();
I created hello.o using the command:
msp430-gcc -mmcu=msp430f1611 hello.c -o hello.o
I created an archive file:
ar -cvq libhello.a hello.o
I move to contiki, i write a simple program that calls hello.h to execute a function.I try to include hello.a using PROJECT LIBRARIES variable in the makefile, when i compile i get this :
Hello_lib.sky section .vectors' will not fit in region'vectors'
...
region vectors overflowed by 32 Bytes
Can someone please explain me what is the problem (I am new to the field) ?
And how to correct it if possible? ( What options should i specify for msp430-gcc) Thanks.
Make sure you build the library for the same architecture you build your program.
For example, if you want to use build an executable for sky
motes (MSP430F1611 MCU), build the library with:
msp430-gcc -mmcu=msp430f1611 -c hello.c -o hello.o
msp430-ar -cvq libhello.a hello.o
Then add the path to the library and its name to application's Makefile:
TARGET_LIBFILES += -L./hellolib -lhello
Then build the application as usual:
make TARGET=sky
This video shows how to add your own libraries to Contiki OS
https://www.youtube.com/watch?v=csa9D1U5R_8
Details:
Steps of the video:
Create folder example:
Copy the example-broadcast.c
Copy the Makefile
Create the library:
Create object file:
msp430-gcc -mmcu=msp430f1611 -c hello.c -o hello.o
Create library file:
msp430-ar -cvq libhello.a hello.o
Tell Contiki the path to the library:
TARGET_LIBFILES += -L. -lhello
Add the library to your .c code and print the hello message:
#include "hello.h"
Print_Function();
Compile your .c code:
make example-broadcast TARGET=sky
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With