OpenWrt Forum Archive

Topic: Static glib, iconv confusion

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

I spent last few days playing with my wl500gp and af9015 based DVB-T tuner. I decided to use getstream for streaming channels over the network.
It just seems to me a little faster than mumudvb. I've got everything working now and it works quite well. My next goal is to write getstream package
makefile which could be used by anyone.

The downside of getstream is its glib dependancy and its size. So i thought it could be linked statically to include just what is needed and save some space
when glib is not required by other apps.

So i changed LIBS in makefile to this

LIBS="-Wl,-Bstatic,-lglib-2.0,-Bdynamic -lpthread -levent"

but linker complains about missing iconv implementation

mipsel-openwrt-linux-uclibc-gcc  -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -fhonour-opts -msoft-float -I/home/pavel/openwrt/backfire/staging_dir/target-mipsel_uClibc-0.9.30.1/sr/include/glib-2.0/ -o getstream getstream.o fe.o crc32.o libhttp.o libconf.o config.o uti.o logging.o stream.o input.o output.o output_http.o output_udp.o output_pipe.o output_rtp. dmx.o dvr.o pat.o pmt.o psi.o simplebuffer.o sap.o socket.o -Wl,-Bstatic,-lglib-2.0,-Bdynaic -lpthread -levent
/home/pavel/openwrt/backfire/staging_dir/target-mipsel_uClibc-0.9.30.1/usr/lib/libglib-2.0.(gconvert.o): In function `g_iconv_close':
gconvert.c:(.text+0x83c): undefined reference to `iconv_close'
...

adding -liconv didn't help either, ld says it cannot find -liconv.

then i did

cd staging_dir/target-mipsel_uClibc-0.9.30.1/usr/lib/
nm -A libglib-2.0.a libglib-2.0.so | grep ' iconv_'

libglib-2.0.a:gconvert.o:         U iconv_close
libglib-2.0.a:gconvert.o:         U iconv_open
libglib-2.0.so:0009d0a8 t iconv_close
libglib-2.0.so:0009cf60 t iconv_open

so, only shared version of the library contains iconv implementation ?

I finally managed to link it  by adding  $(STAGING_DIR)/usr/lib/libiconv-stub/lib/libiconv.a to the end of the LIBS.

And it works, but if libiconv.a is only a stub then where is the real library?  And what is a proper way to do this if i want others be able to use it?

The whole build section of makefile.

define Build/Compile
     $(MAKE) -C $(PKG_BUILD_DIR) \
         LIBS="-Wl,-Bstatic,-lglib-2.0,-Bdynamic -lpthread -levent $(STAGING_DIR)/usr/lib/libiconv-stub/lib/libiconv.a" \
         LDFLAGS="$(EXTRA_LDFLAGS)" \
         CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include/glib-2.0/" \
         $(TARGET_CONFIGURE_OPTS) \
         CROSS="$(TARGET_CROSS)" \
         ARCH="$(ARCH)" \
         $(1);
endef

I'm using last stable branch with backports because trunk with the new kernel was way slower.

This is my first touch to buildroot so i would appriciate any help.
Thanks

Using the stub is fine, it supports Latin1 (ISO-8859-1), Latin 9 (ISO-8859-15) and UTF-8 which is what most people need.
By adding "include $(INCLUDE_DIR)/nls.mk" to your OpenWrt Makefile, the appropriate CFLAGS and LDFLAGS for iconv should be added automatically.

If the autopopulated TARGET_LDFLAGS are not enough use the $(ICONV_LDFLAGS) variable exported by nls.mk to refer to iconv library.

The discussion might have continued from here.