OpenWrt Forum Archive

Topic: [solved] how the package src code read content of .config

The content of this topic has been archived on 5 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I built a package for openwrt following instructions here: http://wiki.openwrt.org/doc/devel/packages

I wrote a config.in file to add a submenu into menuconfig. it works fine, and i can see those "CONFIG_XXXX" in .config. but my source code seemed to be unaware of those CONFIG_XXXX. the code segment enclosed with CONFIG_XXXX didn't compile at all.

Any idea?

(Last edited by nossiac on 23 Dec 2013, 06:20)

Here's the scenario where I got stuck.
------------------------------

config.in

config  MAXLEN
    int "max length"
    default 1024

.config

CONFIG_MAXLEN=1024

test.c

int len = CONFIG_MAXLEN; # compiler complains. no such symbol.

You need to pass them as defines to your compiler, e.g. In the OpenWrt Makefile:

TARGET_CFLAGS += -DCONFIG_MAXLEN="$(CONFIG_MAXLEN)"

thanks, jow,

You're always helpful and enlightening.

The discussion might have continued from here.