OpenWrt Forum Archive

Topic: libiconv compile isssue

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

Hi Forum!

As my vdr(1.7.27) Makefile works now, i realized that i have to compile wscan. big_smile
Buiseness as usal i created a Makefile. Compiler dies with:

char-coding.o: In function `char_coding':
char-coding.c:(.text+0x6b8): undefined reference to `libiconv_open'
char-coding.c:(.text+0x77c): undefined reference to `libiconv'
char-coding.c:(.text+0x81c): undefined reference to `libiconv_close'

As i found here :

http://www.absolutelytech.com/2010/12/0 … compiling/

i need to add "CFLAGS=-liconv".

Ok Sir! Lets do so! i added to openwrt Makefile:

EXTRA_CFLAGS += \
    -liconv

But now configure dies wit :

KRITZELKRATZELKRITZELKRATZELNOONEUNDERSTANDTHISHERE
checking for arm-openwrt-linux-gcc... arm-openwrt-linux-uclibcgnueabi-gcc
checking whether the C compiler works... no
configure: error: in `/home/derdigge/build/dvb2/build_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/w_scan-20121111':
configure: error: C compiler cannot create executables

I am a littlebit confused! What i am doin wrong?

derdigge

a) -liconv goes to LDFLAGS, not CFLAGS
b) to make the build system find an inconv implementation, add  "include $(INCLUDE_DIR)/nls.mk" after include package.mk

Thanks for your reply jow wink
You are allways verry quick!

TARGET_LDFLAGS += \
    -liconv

liconf is there now, but i have same result ??

arm-openwrt-linux-uclibcgnueabi-gcc -Wall -Wextra -Wno-comment -Wswitch-default -Wno-unused-parameter -Os -pipe -march=armv5te -mtune=xscale -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float -I/home/derdigge/build/dvb2/staging_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/usr/lib/libiconv-stub/include -I/home/derdigge/build/dvb2/staging_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/usr/lib/libintl-stub/include   -L/home/derdigge/build/dvb2/staging_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/usr/lib -L/home/derdigge/build/dvb2/staging_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/lib -L/home/derdigge/build/dvb2/staging_dir/toolchain-arm_v5te_gcc-4.6-linaro_uClibc-0.9.33.2_eabi/usr/lib -L/home/derdigge/build/dvb2/staging_dir/toolchain-arm_v5te_gcc-4.6-linaro_uClibc-0.9.33.2_eabi/lib -L/home/derdigge/build/dvb2/staging_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/usr/lib/libiconv-stub/lib -L/home/derdigge/build/dvb2/staging_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/usr/lib/libintl-stub/lib -liconv  -o w_scan atsc_psip_section.o countries.o descriptors.o diseqc.o dump-dvbscan.o dump-kaffeine.o dump-vdr.o dump-xine.o dump-mplayer.o dump-vlc-m3u.o dvbscan.o lnb.o parse-dvbscan.o satellites.o scan.o section.o iconv_codes.o char-coding.o
char-coding.o: In function `char_coding':
char-coding.c:(.text+0x6b8): undefined reference to `iconv_open'
char-coding.c:(.text+0x77c): undefined reference to `iconv'
char-coding.c:(.text+0x81c): undefined reference to `iconv_close'
collect2: ld returned 1 exit status

complete Makefile looks like:

#
# Copyright (C) 2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#    http://wirbel.htpc-forum.de/w_scan/w_scan-20121111.tar.bz2

include $(TOPDIR)/rules.mk

PKG_NAME:=w-scan
PKG_VERSION:=20121111
PKG_RELEASE:=1

PKG_SOURCE:=w_scan-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=http://wirbel.htpc-forum.de/w_scan
PKG_BUILD_DIR:=$(BUILD_DIR)/w_scan-$(PKG_VERSION)

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/nls.mk

define Package/w_scan
  SECTION:=Tvstuff
  CATEGORY:=Tvstuff
  DEPENDS:=+libiconv-full
  TITLE:=w_scan
  URL:=http://wirbel.htpc-forum.de/w_scan/index2.html
endef
    
TARGET_LDFLAGS += \
    -liconv
        
define Package/w_scan/description
    I am Weasel
endef

define Package/w_scan/install
    $(INSTALL_DIR) $(1)/usr/bin
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/w_scan $(1)/usr/bin/
endef

$(eval $(call BuildPackage,w_scan))

(Last edited by derdigge on 18 Jan 2013, 14:54)

Its a problem of w_scan's Makefiles, linked libraries must appear after the objects using them.
You need to patch the shipped Makefile.am and add "w_scan_LDADD= -liconv" before bin_SCRIPTS, then add a "PKG_FIXUP:=autoreconf" to your OpenWrt makefile and remove "TARGET_LDFLAGS += -liconv" from it.

The Machine really hates me today wink

#
# Copyright (C) 2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#http://wirbel.htpc-forum.de/w_scan/w_scan-20121111.tar.bz2

include $(TOPDIR)/rules.mk

PKG_NAME:=w-scan
PKG_VERSION:=20121111
PKG_RELEASE:=1

PKG_SOURCE:=w_scan-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=http://wirbel.htpc-forum.de/w_scan
PKG_BUILD_DIR:=$(BUILD_DIR)/w_scan-$(PKG_VERSION)
PKG_FIXUP:=autoreconf

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/nls.mk

define Package/w_scan
  SECTION:=Tvstuff
  CATEGORY:=Tvstuff
  DEPENDS:=+libiconv-full
  TITLE:=w_scan
  URL:=http://wirbel.htpc-forum.de/w_scan/index2.html
endef
        
define Package/w_scan/description
    I am Weasel
endef

define Build/Configure
    $(call Build/Configure/Default,)
    cp .files/Makefile.am $(PKG_BUILD_DIR)
endef

define Package/w_scan/install
    $(INSTALL_DIR) $(1)/usr/bin
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/w_scan $(1)/usr/bin/
endef

$(eval $(call BuildPackage,w_scan))

Automake does repeat its output several times wink

make[3]: Entering directory `/home/derdigge/build/dvb2/build_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/w_scan-20121111'
 cd . && /bin/bash /home/derdigge/build/dvb2/build_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/w_scan-20121111/missing --run automake-1.11 --gnu Makefile
configure.in:8: version mismatch.  This is Automake 1.11.3,
configure.in:8: but the definition used by this AM_INIT_AUTOMAKE
configure.in:8: comes from Automake 1.11.5.  You should recreate
configure.in:8: aclocal.m4 with aclocal and run automake again.
Makefile.add:1: shell date +%Y%m%d: non-POSIX variable name
Makefile.add:1: (probably a GNU make extension)
Makefile.am:12:   `Makefile.add' included from here
Makefile.add:2: shell cat configure.in | grep AC_INIT | sed -e "s|\[|\\\[|g" -e "s|\]|\\\]|g": non-POSIX variable name
Makefile.add:2: (probably a GNU make extension)
Makefile.am:12:   `Makefile.add' included from here
WARNING: `automake-1.11' is probably too old.  You should only need it if
         you modified `Makefile.am', `acinclude.m4' or `configure.in'.
         You might want to install the `Automake' and `Perl' packages.
         Grab them from any GNU archive site.
 cd . && /bin/bash ./config.status Makefile depfiles
config.status: creating Makefile
config.status: executing depfiles commands
make[3]: Leaving directory `/home/derdigge/build/dvb2/build_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/w_scan-20121111'
make[3]: Entering directory `/home/derdigge/build/dvb2/build_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/w_scan-20121111'
make  all-am
make[4]: Entering directory `/home/derdigge/build/dvb2/build_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/w_scan-20121111'
arm-openwrt-linux-uclibcgnueabi-gcc -Wall -Wextra -Wno-comment -Wswitch-default -Wno-unused-parameter -Os -pipe -march=armv5te -mtune=xscale -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float -I/home/derdigge/build/dvb2/staging_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/usr/lib/libiconv-stub/include -I/home/derdigge/build/dvb2/staging_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/usr/lib/libintl-stub/include   -L/home/derdigge/build/dvb2/staging_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/usr/lib -L/home/derdigge/build/dvb2/staging_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/lib -L/home/derdigge/build/dvb2/staging_dir/toolchain-arm_v5te_gcc-4.6-linaro_uClibc-0.9.33.2_eabi/usr/lib -L/home/derdigge/build/dvb2/staging_dir/toolchain-arm_v5te_gcc-4.6-linaro_uClibc-0.9.33.2_eabi/lib -L/home/derdigge/build/dvb2/staging_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/usr/lib/libiconv-stub/lib -L/home/derdigge/build/dvb2/staging_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/usr/lib/libintl-stub/lib -liconv  -o w_scan atsc_psip_section.o countries.o descriptors.o diseqc.o dump-dvbscan.o dump-kaffeine.o dump-vdr.o dump-xine.o dump-mplayer.o dump-vlc-m3u.o dvbscan.o lnb.o parse-dvbscan.o satellites.o scan.o section.o iconv_codes.o char-coding.o
char-coding.o: In function `char_coding':
char-coding.c:(.text+0x6b8): undefined reference to `iconv_open'
char-coding.c:(.text+0x77c): undefined reference to `iconv'
char-coding.c:(.text+0x81c): undefined reference to `iconv_close'

a) You need to copy the modified .am file *before*calling the default actions
b) Don't depend on libiconv-full

still nothing.
i did :

make package/wscan/prepare V=99

*did the changes by hand here 1st try*

make package/wscan/configure V=99

*did the changes by hand here in the 2nd try*

make package/wscan/compile V=99

Both result in:

KRITZELKRATZELKRITZELKRATZEL
----- SNIP -----
make[3]: Entering directory `/home/derdigge/build/dvb2/build_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/w_scan-20121111'
 cd . && /bin/bash /home/derdigge/build/dvb2/build_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/w_scan-20121111/missing --run automake-1.11 --gnu Makefile
configure.in:8: version mismatch.  This is Automake 1.11.3,
configure.in:8: but the definition used by this AM_INIT_AUTOMAKE
configure.in:8: comes from Automake 1.11.5.  You should recreate
configure.in:8: aclocal.m4 with aclocal and run automake again.
Makefile.add:1: shell date +%Y%m%d: non-POSIX variable name
Makefile.add:1: (probably a GNU make extension)
Makefile.am:12:   `Makefile.add' included from here
Makefile.add:2: shell cat configure.in | grep AC_INIT | sed -e "s|\[|\\\[|g" -e "s|\]|\\\]|g": non-POSIX variable name
Makefile.add:2: (probably a GNU make extension)
Makefile.am:12:   `Makefile.add' included from here
WARNING: `automake-1.11' is probably too old.  You should only need it if
         you modified `Makefile.am', `acinclude.m4' or `configure.in'.
         You might want to install the `Automake' and `Perl' packages.
         Grab them from any GNU archive site.
 cd . && /bin/bash ./config.status Makefile depfiles
config.status: creating Makefile
config.status: executing depfiles commands
make[3]: Leaving directory `/home/derdigge/build/dvb2/build_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/w_scan-20121111'
make[3]: Entering directory `/home/derdigge/build/dvb2/build_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/w_scan-20121111'
make  all-am
----- SNIP -----
a lot more of KRITZELKRATZELKRITZELKRATZEL ;)
----- SNIP -----
arm-openwrt-linux-uclibcgnueabi-gcc -Wall -Wextra -Wno-comment -Wswitch-default -Wno-unused-parameter -Os -pipe -march=armv5te -mtune=xscale -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float -I/home/derdigge/build/dvb2/staging_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/usr/lib/libiconv-stub/include -I/home/derdigge/build/dvb2/staging_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/usr/lib/libintl-stub/include   -L/home/derdigge/build/dvb2/staging_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/usr/lib -L/home/derdigge/build/dvb2/staging_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/lib -L/home/derdigge/build/dvb2/staging_dir/toolchain-arm_v5te_gcc-4.6-linaro_uClibc-0.9.33.2_eabi/usr/lib -L/home/derdigge/build/dvb2/staging_dir/toolchain-arm_v5te_gcc-4.6-linaro_uClibc-0.9.33.2_eabi/lib -L/home/derdigge/build/dvb2/staging_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/usr/lib/libiconv-stub/lib -L/home/derdigge/build/dvb2/staging_dir/target-arm_v5te_uClibc-0.9.33.2_eabi/usr/lib/libintl-stub/lib -liconv  -o w_scan atsc_psip_section.o countries.o descriptors.o diseqc.o dump-dvbscan.o dump-kaffeine.o dump-vdr.o dump-xine.o dump-mplayer.o dump-vlc-m3u.o dvbscan.o lnb.o parse-dvbscan.o satellites.o scan.o section.o iconv_codes.o char-coding.o
char-coding.o: In function `char_coding':
char-coding.c:(.text+0x6b8): undefined reference to `iconv_open'
char-coding.c:(.text+0x77c): undefined reference to `iconv'
char-coding.c:(.text+0x81c): undefined reference to `iconv_close'

Do the following:

  1. Remove the cp .files/Makefile.am $(PKG_BUILD_DIR) line from Configure section of your OpenWRT Makefile for the w_scan package.

  2. While inside the root directory of w_scan package, use quilt to create a patched file against the Makefile.am file (quilt new 000-Makefile_am.patch).

  3. Edit the Makefile.am using quilt (quilt edit Makefile.am) and add w_scan_LDADD= -liconv line before the bin_SCRIPTS line as pointed out by jow. Then, after saving the file, execute quilt refresh. you can use quilt diff to see the difference created by the patched file.

  4. Go to your OpenWRT root directory and run make package/w_scan/update QUILT=1 V=s. This will update your w_scan package with the newly created patched file.

  5. Start compiling your w_scan as usual.

For further information on how to work with patches using quilt,, please perusal this working with patches documentation.

Bam!
Thank you! i learn so much here wink

The discussion might have continued from here.