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


Nashif, Anas
 

Hi,

The Kconfig options (macro) you define need to be included (sourced) in the overall Kconfig structure of zephyr, just adding an option to prj.conf does not give you what you want. This is possible and there are a few examples for doing this, see

 

tests/benchmarks/object_footprint/: This test uses local Kconfig variables

samples/application_development/: A few samples for linking external libraries and 3rd party code.

 

Anas

 

From: zephyr-devel-bounces@... [mailto:zephyr-devel-bounces@...] On Behalf Of Li, Jun R
Sent: Sunday, September 3, 2017 2:29 AM
To: zephyr-devel@...
Subject: [Zephyr-devel] how to conditionally link a static library in Zephyr?

 

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.

 

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!

 

Regards,

Jun

 

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