[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Help wanted with bkgd() rookie mistake
From: |
Thomas Dickey |
Subject: |
Re: Help wanted with bkgd() rookie mistake |
Date: |
Sun, 5 Jan 2025 14:08:43 -0500 |
On Sun, Jan 05, 2025 at 12:49:13PM -0600, G. Branden Robinson wrote:
> At 2025-01-05T13:33:02-0500, Thomas Dickey wrote:
> > On Sun, Jan 05, 2025 at 12:17:15PM -0600, G. Branden Robinson wrote:
> > > At 2025-01-05T13:06:31-0500, Bill Gray wrote:
> > > > On 1/5/25 11:23, G. Branden Robinson wrote:
> > > > > In both, I expect the background character to be set to an
> > > > > underlined @ sign.
> > > >
> > > > I see the background as underlined @ signs with both programs.
> > > > I'm using (default, system-installed, now getting to be elderly)
> > > > ncurses 6.2.20200212. So perhaps a behavior change between then
> > > > and now?
> > >
> > > Hmm. That may be. I'm on the bleeding edge with 6.5.20250104.
> >
> > Both programs look fine to me, but I don't replace the system
> > (n)curses, but rather use the test-packages whose build-scripts are in
> > the "packages" directory.
>
> I'm not replacing the system ncurses, but installing to
> "$HOME/ncurses-HEAD/".
>
> > bkgd:
> > linux-vdso.so.1 (0x00007ffc5b99a000)
> > libncursesw6.so.6 => /lib/x86_64-linux-gnu/libncursesw6.so.6
> > (0x00007f43130c7000)
> > libtinfow6.so.6 => /lib/x86_64-linux-gnu/libtinfow6.so.6
> > (0x00007f431308c000)
> > libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4312eab000)
> > /lib64/ld-linux-x86-64.so.2 (0x00007f431313b000)
>
> Hmm. ldd is a red herring for me. When I reinstall ncurses "HEAD", my
> ldd output doesn't change.
>
> (I seem to remember reading a cautionary note that ldd itself could be a
> vector for security attacks due to the fact that it tries to dynamically
> resolve which ELF objects to load. But I seem to be getting less
> dynamism than I expected.)
>
> LD_LIBRARY_PATH seems to work in general, though. I know because when I
> let my ordinary environment, which preferentially looks in
> $HOME/ncurses-HEAD, prevail, neomutt core dumps with modern ncurses. I
> have to defeat my LD_LIBRARY_PATH just for that program.
>
> $ make
> cc -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 bkgd.c -o bkgd -lncurses -ltinfo
> cc -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600
> -I/home/branden/ncurses-HEAD/include/ncursesw
> -I/home/branden/ncurses-HEAD/include bkgrnd.c -o bkgrnd
> -L/home/branden/ncurses-HEAD/lib -lncursesw -ltinfow -ldb
The -L option isn't doing much, because the system is picking the library.
If you add a -v to the command, it'll show what it's doing.
for example -
LIB=/usr/local/ncurses/lib
ls -l $LIB/*ncurses.*
echo .............
gcc -v -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 bkgd.c -o bkgd -L $LIB -lncurses
-ltinfo
echo .............
ldd bkgd
echo .............
LD_LIBRARY_PATH=$LIB ldd bkgd
gives me an executable that ldd says is linked to the system:
lrwxrwxrwx 1 root staff 15 Jan 4 19:47
/usr/local/ncurses/lib/libncurses.so -> libncurses.so.5
lrwxrwxrwx 1 root staff 17 Jan 4 19:47
/usr/local/ncurses/lib/libncurses.so.5 -> libncurses.so.5.9
-rw-r--r-- 1 root staff 231872 Jan 4 19:46
/usr/local/ncurses/lib/libncurses.so.5.9
.............
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/12/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 12.2.0-14'
--with-bugurl=file:///usr/share/doc/gcc-12/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-12
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin
--enable-default-pie --with-system-zlib --enable-libphobos-checking=release
--with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch
--disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-12-bTRWOB/gcc-12-12.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-12-bTRWOB/gcc-12-12.2.0/debian/tmp-gcn/usr
--enable-offload-defaulted --without-cuda-driver --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (Debian 12.2.0-14)
COLLECT_GCC_OPTIONS='-v' '-D' '_DEFAULT_SOURCE' '-D' '_XOPEN_SOURCE=600' '-o'
'bkgd' '-L/usr/local/ncurses/lib' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-linux-gnu/12/cc1 -quiet -v -imultiarch x86_64-linux-gnu -D
_DEFAULT_SOURCE -D _XOPEN_SOURCE=600 bkgd.c -quiet -dumpbase bkgd.c
-dumpbase-ext .c -mtune=generic -march=x86-64 -version
-fasynchronous-unwind-tables -o /var/tmp/ccxOBSLR.s
GNU C17 (Debian 12.2.0-14) version 12.2.0 (x86_64-linux-gnu)
compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version
4.1.1-p1, MPC version 1.3.1, isl version isl-0.25-GMP
warning: MPFR header version 4.1.1-p1 differs from library version 4.2.0.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/12/include-fixed"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-linux-gnu/12/include
/usr/local/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
GNU C17 (Debian 12.2.0-14) version 12.2.0 (x86_64-linux-gnu)
compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version
4.1.1-p1, MPC version 1.3.1, isl version isl-0.25-GMP
warning: MPFR header version 4.1.1-p1 differs from library version 4.2.0.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: cc72d2b9b5048fedc2be9051c917b40b
COLLECT_GCC_OPTIONS='-v' '-D' '_DEFAULT_SOURCE' '-D' '_XOPEN_SOURCE=600' '-o'
'bkgd' '-L/usr/local/ncurses/lib' '-mtune=generic' '-march=x86-64'
as -v --64 -o /var/tmp/ccOszI07.o /var/tmp/ccxOBSLR.s
GNU assembler version 2.40 (x86_64-linux-gnu) using BFD version (GNU Binutils
for Debian) 2.40
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/12/:/usr/lib/gcc/x86_64-linux-gnu/12/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/12/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/12/:/usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/12/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/12/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-D' '_DEFAULT_SOURCE' '-D' '_XOPEN_SOURCE=600' '-o'
'bkgd' '-L/usr/local/ncurses/lib' '-mtune=generic' '-march=x86-64' '-dumpdir'
'bkgd.'
/usr/lib/gcc/x86_64-linux-gnu/12/collect2 -plugin
/usr/lib/gcc/x86_64-linux-gnu/12/liblto_plugin.so
-plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/12/lto-wrapper
-plugin-opt=-fresolution=/var/tmp/cc14Ais9.res -plugin-opt=-pass-through=-lgcc
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id
--eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker
/lib64/ld-linux-x86-64.so.2 -pie -o bkgd
/usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/Scrt1.o
/usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/crti.o
/usr/lib/gcc/x86_64-linux-gnu/12/crtbeginS.o -L/usr/local/ncurses/lib
-L/usr/lib/gcc/x86_64-linux-gnu/12
-L/usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu
-L/usr/lib/gcc/x86_64-linux-gnu/12/../../../../lib -L/lib/x86_64-linux-gnu
-L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib
-L/usr/lib/gcc/x86_64-linux-gnu/12/../../.. /var/tmp/ccOszI07.o -lncurses
-ltinfo -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc
--push-state --as-needed -lgcc_s --pop-state
/usr/lib/gcc/x86_64-linux-gnu/12/crtendS.o
/usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/crtn.o
COLLECT_GCC_OPTIONS='-v' '-D' '_DEFAULT_SOURCE' '-D' '_XOPEN_SOURCE=600' '-o'
'bkgd' '-L/usr/local/ncurses/lib' '-mtune=generic' '-march=x86-64' '-dumpdir'
'bkgd.'
.............
linux-vdso.so.1 (0x00007fffddfda000)
libncurses.so.5 => /lib/x86_64-linux-gnu/libncurses.so.5
(0x00007f5409a49000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5
(0x00007f5409a18000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5409837000)
/lib64/ld-linux-x86-64.so.2 (0x00007f5409a99000)
.............
libncurses.so.5 => /usr/local/ncurses/lib/libncurses.so.5
(0x00007fa8f8539000)
libtinfo.so.5 => /usr/local/ncurses/lib/libtinfo.so.5
(0x00007fa8f8503000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa8f82ff000)
/lib64/ld-linux-x86-64.so.2 (0x00007fa8f8573000)
That last LD_LIBRARY_PATH shows a different library. It'll satisfy ldd
either way, but the program linked (compile-time/link) against the
libncurses.so.5 won't behave as expected because the offsets to the
video-attribute changed between ABI 5 and 6.
(you could force it to ignore the default library path using the rpath
feature, but that's a nuisance for one-offs).
> Any suggestions for where to look for the cause of the trouble?
>
> > and defining NCURSES_WIDECHAR when compiling.
>
> Hmm, I use "./configure --enable-widec". Is that different?
>
> I'm attaching my scripts for configuring and rebuilding ncurses; let me
> know if anything looks stupid.
>
> While I'm at it I'll include my Makefile for my examples. Very simple.
> Very crude.
>
> > I have seen comments that ncurses-examples aren't simple...
>
> People may have noticed that I contribute a lot of patches to the man
> pages, so often I need to write something micro-targeted at a specific
> API call. Often, I want to see what the library does with invalid
> inputs. Your test programs and examples have value, but they're more
> like integration tests and demos.
>
> Regards,
> Branden
> #!/bin/sh
>
> # autoreconf-dickey -f -i
>
> ./configure \
> --prefix=$HOME/ncurses-HEAD \
> --with-shared \
> --with-cxx-shared \
> --with-hashed-db \
> --with-manpage-format=normal \
> --with-termlib \
> --with-versioned-syms \
> --enable-widec \
> --enable-opaque-curses \
> --enable-opaque-form \
> --enable-opaque-menu \
> --enable-opaque-panel \
>
> # --with-shlib-version=rel \
> # --with-ada-sharedlib \ "no GNAT project support"
> # --with-config-suffix=GBRINFIX \
>
> # --enable-pc-files \
> # --with-pkg-config \
> # --with-pc-suffix=GBRSUFFIX \
> NDIR:=$(HOME)/ncurses-HEAD
>
> CFLAGS_NARROW:=$(shell ncurses6-config --cflags)
> LDFLAGS_NARROW:=$(shell ncurses6-config --libs)
> CFLAGS_WIDE:=$(shell ncursesw6-config --cflags)
> LDFLAGS_WIDE:=$(shell ncursesw6-config --libs)
>
> ALL:=hello_mouse hello_narrow hello_wide insch nl nl2 \
> simple termcap waddch wresize wsimple getyx termsize wunctrl \
> define-key cooked instr inwstr getstr get_wstr scroll \
> bkgd_uninitialized bkgd bkgrnd_uninitialized bkgrnd \
> addch_uninitialized addch add_wch_uninitialized add_wch
>
> # not working yet: wadd_wch
>
> all: $(ALL)
>
> clean:
> $(RM) $(ALL)
>
> hello_mouse: hello_mouse.c
> $(CC) $(CFLAGS_WIDE) $< -o $@ $(LDFLAGS_WIDE)
>
> hello_narrow: hello_narrow.c
> $(CC) $(CFLAGS_NARROW) $< -o $@ $(LDFLAGS_NARROW)
>
> hello_wide: hello_wide.c
> $(CC) $(CFLAGS_WIDE) $< -o $@ $(LDFLAGS_WIDE)
>
> insch: insch.c
> $(CC) $(CFLAGS_NARROW) $< -o $@ $(LDFLAGS_NARROW)
>
> nl: nl.c
> $(CC) $(CFLAGS_NARROW) $< -o $@ $(LDFLAGS_NARROW)
>
> nl2: nl2.c
> $(CC) $(CFLAGS_NARROW) $< -o $@ $(LDFLAGS_NARROW)
>
> simple: simple.c
> $(CC) $(CFLAGS_NARROW) $< -o $@ $(LDFLAGS_NARROW)
>
> wresize: wresize.c
> $(CC) $(CFLAGS_WIDE) $< -o $@ $(LDFLAGS_WIDE)
>
> wsimple: wsimple.c
> $(CC) $(CFLAGS_WIDE) $< -o $@ $(LDFLAGS_WIDE)
>
> termcap: termcap.c
> $(CC) $(CFLAGS_WIDE) $< -o $@ $(LDFLAGS_WIDE)
>
> waddch: waddch.c
> $(CC) $(CFLAGS_NARROW) $< -o $@ $(LDFLAGS_NARROW)
>
> wadd_wch: wadd_wch.c
> $(CC) $(CFLAGS_NARROW) $< -o $@ $(LDFLAGS_NARROW)
>
> getyx: getyx.c
> $(CC) $(CFLAGS_NARROW) $< -o $@ $(LDFLAGS_NARROW)
>
> termsize: termsize.c
> $(CC) $(CFLAGS_NARROW) $< -o $@ $(LDFLAGS_NARROW)
>
> wunctrl: wunctrl.c
> $(CC) $(CFLAGS_WIDE) $< -o $@ $(LDFLAGS_WIDE)
>
> define-key: define-key.c
> $(CC) $(CFLAGS_NARROW) $< -o $@ $(LDFLAGS_NARROW)
>
> cooked: cooked.c
> $(CC) $(CFLAGS_NARROW) $< -o $@ $(LDFLAGS_NARROW)
>
> instr: instr.c
> $(CC) $(CFLAGS_NARROW) $< -o $@ $(LDFLAGS_NARROW)
>
> inwstr: inwstr.c
> $(CC) $(CFLAGS_WIDE) $< -o $@ $(LDFLAGS_WIDE)
>
> getstr: getstr.c
> $(CC) $(CFLAGS_NARROW) $< -o $@ $(LDFLAGS_NARROW)
>
> get_wstr: get_wstr.c
> $(CC) $(CFLAGS_NARROW) $< -o $@ $(LDFLAGS_WIDE)
>
> scroll: scroll.c
> $(CC) $(CFLAGS_NARROW) $< -o $@ $(LDFLAGS_NARROW)
>
> bkgd_uninitialized: bkgd_uninitialized.c
> $(CC) $(CFLAGS_NARROW) $< -o $@ $(LDFLAGS_NARROW)
>
> bkgd: bkgd.c
> $(CC) $(CFLAGS_NARROW) $< -o $@ $(LDFLAGS_NARROW)
>
> bkgrnd_uninitialized: bkgrnd_uninitialized.c
> $(CC) $(CFLAGS_WIDE) $< -o $@ $(LDFLAGS_WIDE)
>
> bkgrnd: bkgrnd.c
> $(CC) $(CFLAGS_WIDE) $< -o $@ $(LDFLAGS_WIDE)
>
> addch_uninitialized: addch_uninitialized.c
> $(CC) $(CFLAGS_NARROW) $< -o $@ $(LDFLAGS_NARROW)
>
> addch: addch.c
> $(CC) $(CFLAGS_NARROW) $< -o $@ $(LDFLAGS_NARROW)
>
> add_wch_uninitialized: add_wch_uninitialized.c
> $(CC) $(CFLAGS_WIDE) $< -o $@ $(LDFLAGS_WIDE)
>
> add_wch: add_wch.c
> $(CC) $(CFLAGS_WIDE) $< -o $@ $(LDFLAGS_WIDE)
--
Thomas E. Dickey <dickey@invisible-island.net>
https://invisible-island.net
signature.asc
Description: PGP signature
- Help wanted with bkgd() rookie mistake, G. Branden Robinson, 2025/01/05
- Re: Help wanted with bkgd() rookie mistake, Bill Gray, 2025/01/05
- Re: Help wanted with bkgd() rookie mistake, G. Branden Robinson, 2025/01/05
- Re: Help wanted with bkgd() rookie mistake, Thomas Dickey, 2025/01/05
- Re: Help wanted with bkgd() rookie mistake, G. Branden Robinson, 2025/01/05
- Re: Help wanted with bkgd() rookie mistake,
Thomas Dickey <=
- Re: Help wanted with bkgd() rookie mistake, G. Branden Robinson, 2025/01/05
- SOLVED: Help wanted with bkgd() rookie mistake, G. Branden Robinson, 2025/01/05
- Re: Help wanted with bkgd() rookie mistake, Thomas Dickey, 2025/01/05