Re: how to conditionally link a static library in Zephyr?

Paul Sokolovsky


On Sun, 3 Sep 2017 06:28:52 +0000
"Li, Jun R" <> wrote:

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
Well, that's not specific enough. It's not enough to define a config
option "in a Kconfig file somewhere" for it to be actually available in
Zephyr build process. Nor you explain which Makefile contains
ifeq/endif snippet above.

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
With the (sparse) info above, I'd suggest checking that
outdir/$BOARD/.config actually contains CONFIG_ENABLE_MYLIB=y.

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


Best Regards,
Paul | Open source software for ARM SoCs
Follow Linaro:!/linaroorg -

Join to automatically receive all group messages.