A simple example of how to link a static library to your Zephyr project
- Zephyr RTOS v3.1.0
Generate object file (.o
)
arm-none-eabi-gcc -c -o out.o mylib.c
Link and generate static library (.a
)
arm-none-eabi-ar -rcs libmylib.a out.o
add_library(mylib STATIC IMPORTED GLOBAL)
set_target_properties(mylib PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/mylib/libmylib.a)
set_target_properties(mylib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/mylib)
target_link_libraries(app INTERFACE mylib)