how to conditionally link a static library in Zephyr?

Li, Jun R

Hi there,

I’m trying to build my zephyr app with a static library which is not provided with its source code. I can achieve the goal by adding the following two lines in my project’s Makefile:


export LDFLAGS_zephyr += -L$(SOURCE_DIR)/mylib/

export ALL_LIBS += mylib


However, I want to get the static library linked only when a specific macro is defined, like below



export LDFLAGS_zephyr += -L$(SOURCE_DIR)/mylib/

export ALL_LIBS += mylib




Here `CONFIG_ENABLE_MYLIB` is a macro defined in a Kconfig file somewhere.


However, the static library can’t be linked if I used the conditional option even though the macro CONFIG_ENABLE_MYLIB is enabled in my “prj.conf”.


So, I’m wondering if anybody has done the similar work and can you share the experience? Thank you very much!





Join { to automatically receive all group messages.