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


Paul Sokolovsky
 

Hello,

On Sun, 3 Sep 2017 06:28:52 +0000
"Li, Jun R" <jun.r.li@...> 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

Ifeq ($(CONFIG_ENABLE_MYLIB),y)
export LDFLAGS_zephyr += -L$(SOURCE_DIR)/mylib/
export ALL_LIBS += mylib
endif


Here `CONFIG_ENABLE_MYLIB` is a macro defined in a Kconfig file
somewhere.
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
“prj.conf”.
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!

Regards,
Jun


--
Best Regards,
Paul

Linaro.org | Open source software for ARM SoCs
Follow Linaro: http://www.facebook.com/pages/Linaro
http://twitter.com/#!/linaroorg - http://www.linaro.org/linaro-blog

Join devel@lists.zephyrproject.org to automatically receive all group messages.