This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Add static library (.a) to project

Hi,

I'm trying to link a static library that provided by others to my own project. I followed the steps in this post (https://devzone.nordicsemi.com/f/nordic-q-a/39338/segger-studio-static-library-adding-to-linker)  but I got the error 'undefined reference' when I try to use the APIs from that library.

I have included the following lines in my CMakeLists:

zephyr_library_include_directories(
  externlib/inc/
  )

add_library(testlib STATIC IMPORTED)
target_link_libraries(app PUBLIC ${APPLICATION_SOURCE_DIR}/externlib/lib/testlib.a)

And my project folder looks like this:

├--- CMakeLists.txt

├--- prj.conf

├--- nrf9160_pca10090ns.overlay

├--- scr

    └-- main.c

└--- externlib

    └-- inc

        └-- testlib.h #header file to be included

    └-- lib

        └-- testlib.a #library to be added

Please can someone let me know if I missed any steps to include the static library correctly?

Thank you

Arno

Related