Skip to contentSkip to conversation

Fix undefined reference errors on SDK tarball build

PATCH In review Bagas Sanjaya 2 participants 5 messages Sep 20, 2025 – Jan 2

lore
Share & tools
lore
#0 lore raw

cover Fix undefined reference errors on SDK tarball build

Hi,

Here are fixes for undefined reference errors when building buildroot SDK tarball on Arch Linux host [1].

Tested toolchain configuration:

* target gcc 15.2.0
* target binutils 2.44
* host gdb 16.3
* custom kernel headers 6.12 (from kernel.org mainline release [2])

Enjoy!

[1]: https://lore.kernel.org/buildroot/[email protected]/
[2]: https://www.kernel.org/pub/linux/kernel/v6.x/linux-6.12.tar.xz

Bagas Sanjaya (2):
package/readline: Fix sdk rootfs tarball generation package/ncurses: Also build termlib

 package/ncurses/ncurses.mk   | 4 +++-
 package/readline/readline.mk | 4 ++++
 2 files changed, 7 insertions(+), 1 deletion(-)
Signature · 6 lines
An old man doll... just what I always wanted! - Clara

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH 1/2 package/readline: Fix sdk rootfs tarball generation

Generating rootfs.tar when building the sdk fails with undefined reference error on host libreadline:

␛[7m>>> Generating filesystem image rootfs.tar␛[27m
mkdir -p /home/bagas/repo/buildroot/output/images
rm -rf /home/bagas/repo/buildroot/output/build/buildroot-fs/tar
mkdir -p /home/bagas/repo/buildroot/output/build/buildroot-fs/tar
rsync -auH --exclude=/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM /home/bagas/repo/buildroot/output/target/ /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/target
echo '#!/bin/sh' > /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot
echo "set -e" >> /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot
echo "chown -h -R 0:0 /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/target" >> /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot
PATH="/home/bagas/repo/buildroot/output/host/bin:/home/bagas/repo/buildroot/output/host/sbin:/home/bagas/.local/bin:/home/bagas/go/bin:/home/bagas/.local/bin:/home/bagas/.cargo/bin:/home/bagas/.nvm/versions/node/v22.19.0/bin:/home/bagas/go/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl" /home/bagas/repo/buildroot/support/scripts/mkusers /home/bagas/repo/buildroot/output/build/buildroot-fs/full_users_table.txt /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/target >> /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot echo "/home/bagas/repo/buildroot/output/host/bin/makedevs -d /home/bagas/repo/buildroot/output/build/buildroot-fs/full_devices_table.txt /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/target" >> /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot
printf ' rm -rf /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/target/usr/lib/udev/hwdb.d/ /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/target/etc/udev/hwdb.d/\n' >> /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot
echo "find /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/target/run/ -mindepth 1 -prune -print0 | xargs -0r rm -rf --" >> /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot
echo "find /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/target/tmp/ -mindepth 1 -prune -print0 | xargs -0r rm -rf --" >> /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot

printf '   \n' >> /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot
printf '   \n' >> /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot
printf '   	(cd /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/target; find -print0 | LC_ALL=C sort -z | tar  --pax-option=exthdr.name=%%d/PaxHeaders/%%f,atime:=0,ctime:=0 -cf /home/bagas/repo/buildroot/output/images/rootfs.tar --null --xattrs-include='\''*'\'' --no-recursion -T - --numeric-owner)\n' >> /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot

chmod a+x /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot PATH="/home/bagas/repo/buildroot/output/host/bin:/home/bagas/repo/buildroot/output/host/sbin:/home/bagas/.local/bin:/home/bagas/go/bin:/home/bagas/.local/bin:/home/bagas/.cargo/bin:/home/bagas/.nvm/versions/node/v22.19.0/bin:/home/bagas/go/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl" FAKEROOTDONTTRYCHOWN=1 /home/bagas/repo/buildroot/output/host/bin/fakeroot -- /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot /bin/sh: symbol lookup error: /home/bagas/repo/buildroot/output/host/lib/libreadline.so.8: undefined symbol: UP
make: *** [fs/tar/tar.mk:38: /home/bagas/repo/buildroot/output/images/rootfs.tar] Error 127

Fix it by also passing the same configure options as target readline to host readline.

---
 package/readline/readline.mk | 4 ++++
 1 file changed, 4 insertions(+)
package/readline/readline.mk +4 -0
index f69cbe45e2..078607a0c5 100644
@@ -15,6 +15,10 @@ READLINE_CONF_OPTS = \
 	--disable-install-examples \
 	--with-curses \
 	--with-shared-termcap-library
+HOST_READLINE_CONF_OPTS = \
+	--disable-install-examples \
+	--with-curses \
+	--with-shared-termcap-library
 READLINE_LICENSE = GPL-3.0+
 READLINE_LICENSE_FILES = COPYING
 READLINE_CPE_ID_VENDOR = gnu
Signature · 6 lines
An old man doll... just what I always wanted! - Clara

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Re: [Buildroot] [PATCH 1/2] package/readline: Fix sdk rootfs tarball generation

Hello,

Quoted 13 lines · On Sat, 20 Sep 2025 14:47:09 +0700 Bagas Sanjaya <[email protected]> wrote:

␛[7m>>> Generating filesystem image rootfs.tar␛[27m
mkdir -p /home/bagas/repo/buildroot/output/images
rm -rf /home/bagas/repo/buildroot/output/build/buildroot-fs/tar
mkdir -p /home/bagas/repo/buildroot/output/build/buildroot-fs/tar
rsync -auH --exclude=/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM /home/bagas/repo/buildroot/output/target/ /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/target
echo '#!/bin/sh' > /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot
echo "set -e" >> /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot
echo "chown -h -R 0:0 /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/target" >> /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot
PATH="/home/bagas/repo/buildroot/output/host/bin:/home/bagas/repo/buildroot/output/host/sbin:/home/bagas/.local/bin:/home/bagas/go/bin:/home/bagas/.local/bin:/home/bagas/.cargo/bin:/home/bagas/.nvm/versions/node/v22.19.0/bin:/home/bagas/go/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl" /home/bagas/repo/buildroot/support/scripts/mkusers /home/bagas/repo/buildroot/output/build/buildroot-fs/full_users_table.txt /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/target >> /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot echo "/home/bagas/repo/buildroot/output/host/bin/makedevs -d /home/bagas/repo/buildroot/output/build/buildroot-fs/full_devices_table.txt /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/target" >> /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot
printf ' rm -rf /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/target/usr/lib/udev/hwdb.d/ /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/target/etc/udev/hwdb.d/\n' >> /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot
echo "find /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/target/run/ -mindepth 1 -prune -print0 | xargs -0r rm -rf --" >> /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot
echo "find /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/target/tmp/ -mindepth 1 -prune -print0 | xargs -0r rm -rf --" >> /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot

Quoted 7 lines
printf '   \n' >> /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot
printf '   \n' >> /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot
printf '   	(cd /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/target; find -print0 | LC_ALL=C sort -z | tar  --pax-option=exthdr.name=%%d/PaxHeaders/%%f,atime:=0,ctime:=0 -cf /home/bagas/repo/buildroot/output/images/rootfs.tar --null --xattrs-include='\''*'\'' --no-recursion -T - --numeric-owner)\n' >> /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot

chmod a+x /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot PATH="/home/bagas/repo/buildroot/output/host/bin:/home/bagas/repo/buildroot/output/host/sbin:/home/bagas/.local/bin:/home/bagas/go/bin:/home/bagas/.local/bin:/home/bagas/.cargo/bin:/home/bagas/.nvm/versions/node/v22.19.0/bin:/home/bagas/go/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl" FAKEROOTDONTTRYCHOWN=1 /home/bagas/repo/buildroot/output/host/bin/fakeroot -- /home/bagas/repo/buildroot/output/build/buildroot-fs/tar/fakeroot /bin/sh: symbol lookup error: /home/bagas/repo/buildroot/output/host/lib/libreadline.so.8: undefined symbol: UP
make: *** [fs/tar/tar.mk:38: /home/bagas/repo/buildroot/output/images/rootfs.tar] Error 127

This is not the "sdk rootfs tarball generation", just the "rootfs tarball generation". SDK and rootfs generation are two separate things.

However, what exactly is using libreadline here? Is it fakeroot? Something else?

We need a bit more convincing explanation than "adding those lines in readline.mk fixed the problem for me".

Which tool is linked with readline? Is it working at link time because host-readline is not already built, then later on, some other package builds/installs host-readline, and the tool ends up using our host-readline instead of the system-provided readline?

This definitely need more investigation/explanation before we can apply the patch.

Thanks!

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

PATCH 2/2 package/ncurses: Also build termlib

In reply to Bagas Sanjaya

As a side effect of readline fix in previous commit, building host-gdb fails with undefined reference to ncurses error:

CXX init.o
CXXLD gdb
/usr/bin/ld: /home/bagas/repo/buildroot/output/host/lib/libreadline.so: undefined reference to tgoto@NCURSES6_TINFO_5.0.19991023' /usr/bin/ld: /home/bagas/repo/buildroot/output/host/lib/libreadline.so: undefined reference to UP@NCURSES6_TINFO_5.0.19991023' /usr/bin/ld: /home/bagas/repo/buildroot/output/host/lib/libreadline.so: undefined reference to tgetent@NCURSES6_TINFO_5.0.19991023' /usr/bin/ld: /home/bagas/repo/buildroot/output/host/lib/libreadline.so: undefined reference to tgetnum@NCURSES6_TINFO_5.0.19991023' /usr/bin/ld: /home/bagas/repo/buildroot/output/host/lib/libreadline.so: undefined reference to PC@NCURSES6_TINFO_5.0.19991023' /usr/bin/ld: /home/bagas/repo/buildroot/output/host/lib/libreadline.so: undefined reference to tgetstr@NCURSES6_TINFO_5.0.19991023' /usr/bin/ld: /home/bagas/repo/buildroot/output/host/lib/libreadline.so: undefined reference to tgetflag@NCURSES6_TINFO_5.0.19991023' /usr/bin/ld: /home/bagas/repo/buildroot/output/host/lib/libreadline.so: undefined reference to BC@NCURSES6_TINFO_5.0.19991023' /usr/bin/ld: /home/bagas/repo/buildroot/output/host/lib/libreadline.so: undefined reference to `tputs@NCURSES6_TINFO_5.0.19991023'
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:2232: gdb] Error 1

Fix above by also building termlib (libtinfo.so.6) so that host-readline is linked to ncurses from buildroot instead from host distro.

---
 package/ncurses/ncurses.mk | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
package/ncurses/ncurses.mk +3 -1
index 864f62b57c..a837ac96bf 100644
@@ -162,7 +162,9 @@ HOST_NCURSES_CONF_OPTS = \
 	--without-ada \
 	--with-default-terminfo-dir=/usr/share/terminfo \
 	--disable-db-install \
-	--without-normal
+	--without-normal \
+	--with-termlib \
+	--disable-widec
 
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))
Signature · 6 lines
An old man doll... just what I always wanted! - Clara

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw

Re: [Buildroot] [PATCH 2/2] package/ncurses: Also build termlib

Hello,

Thanks for your patch!

Quoted 16 lines · On Sat, 20 Sep 2025 14:47:10 +0700 Bagas Sanjaya <[email protected]> wrote:

As a side effect of readline fix in previous commit, building host-gdb fails with undefined reference to ncurses error:

CXX init.o
CXXLD gdb
/usr/bin/ld: /home/bagas/repo/buildroot/output/host/lib/libreadline.so: undefined reference to tgoto@NCURSES6_TINFO_5.0.19991023' /usr/bin/ld: /home/bagas/repo/buildroot/output/host/lib/libreadline.so: undefined reference to UP@NCURSES6_TINFO_5.0.19991023' /usr/bin/ld: /home/bagas/repo/buildroot/output/host/lib/libreadline.so: undefined reference to tgetent@NCURSES6_TINFO_5.0.19991023' /usr/bin/ld: /home/bagas/repo/buildroot/output/host/lib/libreadline.so: undefined reference to tgetnum@NCURSES6_TINFO_5.0.19991023' /usr/bin/ld: /home/bagas/repo/buildroot/output/host/lib/libreadline.so: undefined reference to PC@NCURSES6_TINFO_5.0.19991023' /usr/bin/ld: /home/bagas/repo/buildroot/output/host/lib/libreadline.so: undefined reference to tgetstr@NCURSES6_TINFO_5.0.19991023' /usr/bin/ld: /home/bagas/repo/buildroot/output/host/lib/libreadline.so: undefined reference to tgetflag@NCURSES6_TINFO_5.0.19991023' /usr/bin/ld: /home/bagas/repo/buildroot/output/host/lib/libreadline.so: undefined reference to BC@NCURSES6_TINFO_5.0.19991023' /usr/bin/ld: /home/bagas/repo/buildroot/output/host/lib/libreadline.so: undefined reference to `tputs@NCURSES6_TINFO_5.0.19991023'
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:2232: gdb] Error 1

Since host-gdb builds fine for most people, there must be something specific to your environment. Could you provide the details of your host distribution + the exact Buildroot version + minimal Buildroot defconfig that exhibits the issue so that people can reproduce ?

To be honest, I don't pretend to fully grasp the interactions between readline, ncurses, termlib, etc. So if you want patches to be merged, they need to come with detailed and convincing explanations :-)

Thanks a lot!

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot