Adding my own library to Contiki OS

倖福魔咒の 提交于 2019-12-05 08:26:37

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:

  • The library that i create is: libhello.a
  • The library just prints the message "Hello everbody, library call"
  • I included the library to the Contiki example "example-broadcast.c"

Steps of the video:

  1. Create folder example:

    • Copy the example-broadcast.c

    • Copy the Makefile

  2. 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
      
  3. Tell Contiki the path to the library:

        TARGET_LIBFILES += -L. -lhello
    
  4. Add the library to your .c code and print the hello message:

     #include "hello.h"
     Print_Function();
    
  5. Compile your .c code:

     make example-broadcast TARGET=sky
    
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!