Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined reference to `waddnwstr' #161

Open
firstlove1992 opened this issue Dec 17, 2022 · 31 comments · May be fixed by #163
Open

undefined reference to `waddnwstr' #161

firstlove1992 opened this issue Dec 17, 2022 · 31 comments · May be fixed by #163
Assignees
Labels

Comments

@firstlove1992
Copy link

[root@dclx cmatrix]# make
make all-am
make[1]: Entering directory /cmat/cmatrix' gcc -g -O2 -o cmatrix cmatrix.o -lncurses -lncurses cmatrix.o: In function main':
/cmat/cmatrix/cmatrix.c:850: undefined reference to waddnwstr' collect2: error: ld returned 1 exit status make[1]: *** [cmatrix] Error 1 make[1]: Leaving directory /cmat/cmatrix'
make: *** [all] Error 2

@abishekvashok
Copy link
Owner

Did you run configure?

@firstlove1992
Copy link
Author

Of course

@firstlove1992
Copy link
Author

[root@dclx cmatrix]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking whether make sets $(MAKE)... (cached) yes
checking for main in -lncurses... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking for unistd.h... (cached) yes
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking termio.h usability... yes
checking termio.h presence... yes
checking for termio.h... yes
checking getopt.h usability... yes
checking getopt.h presence... yes
checking for getopt.h... yes
checking return type of signal handlers... void
checking for putenv... yes
checking curses.h usability... yes
checking curses.h presence... yes
checking for curses.h... yes
checking ncurses.h usability... yes
checking ncurses.h presence... yes
checking for ncurses.h... yes
checking for tgetent in -lncurses... yes
"Using ncurses as the termcap library"
checking for use_default_colors in -lncurses... yes
checking for resizeterm in -lncurses... yes
checking for wresize in -lncurses... yes
checking for consolechars... no
checking for setfont... /usr/bin/setfont
checking for /usr/lib/kbd/consolefonts... yes
checking for /usr/share/consolefonts... no
checking for mkfontdir... /usr/bin/mkfontdir
checking for /usr/share/fonts/misc... no
checking for /usr/share/X11/fonts/misc... yes
checking for /usr/X11R6/lib/X11/fonts/misc... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating cmatrix.spec
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands

@abishekvashok
Copy link
Owner

abishekvashok commented Dec 17, 2022

Can you give me more information about the system (OS). I was guessing it was due to curses not being present but configure tells otherwise.

@firstlove1992
Copy link
Author

It seems that way.
But I reupdated the package and it worked.
Although it reports the following error, but does not affect.
By the way, my version of linux is Red Hat Enterprise Linux Server release 7.6 (Maipo).

wget https://github.com/abishekvashok/cmatrix/archive/refs/tags/v2.0.tar.gz
./configure
checking for /usr/lib/X11/fonts/misc... no
checking for /usr/X11R6/lib/X11/fonts/misc... no
configure: WARNING:

*** You do not appear to have an X window fonts directory in the standard
*** locations (/usr/lib/X11/fonts/misc or /usr/X11R6/lib/X11/fonts/misc). The
*** mtx.pcf font will not be installed. This means you will probably not
*** be able to use the mtx fonts in your x terminals, and hence be unable
*** to use the -x command line switch. Sorry about that...

@firstlove1992
Copy link
Author

firstlove1992 commented Dec 17, 2022

Maybe it's my version of linux.
I don't know, but it's working now.

@abishekvashok
Copy link
Owner

abishekvashok commented Dec 18, 2022

Closing as it is working :)

For the x fonts warning, it means you don't have fonts installed or configured and the -x option won't work properly. Maybe try the latest version instead of the release tarball?

@somera
Copy link

somera commented Dec 21, 2022

Same problem on the current master. Ubuntu 20.04.

make  all-am
make[1]: Entering directory '/data-files/tools/misc/cmatrix'
gcc  -g -O2   -o cmatrix cmatrix.o  -lncurses  -lncurses
/usr/bin/ld: cmatrix.o: in function `main':
/data-files/tools/misc/cmatrix/cmatrix.c:850: undefined reference to `waddnwstr'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:427: cmatrix] Error 1
make[1]: Leaving directory '/data-files/tools/misc/cmatrix'
make: *** [Makefile:328: all] Error 2
[Mi Dez 21][11:28:34][nuc-mini-pentium]:[/data-files/tools/misc/cmatrix]$ ldconfig -p | grep ncurses
        libncursesw.so.6 (libc6,x86-64) => /lib/x86_64-linux-gnu/libncursesw.so.6
        libncursesw.so.5 (libc6,x86-64) => /lib/x86_64-linux-gnu/libncursesw.so.5
        libncurses.so.6 (libc6,x86-64) => /lib/x86_64-linux-gnu/libncurses.so.6
        libncurses.so.5 (libc6,x86-64) => /lib/x86_64-linux-gnu/libncurses.so.5

@abishekvashok
Copy link
Owner

abishekvashok commented Dec 22, 2022

Can you run, @somera
gcc -g -O2 -o cmatrix cmatrix.o -lncurses -lncursesw -v

and post the output?

@abishekvashok abishekvashok reopened this Dec 22, 2022
@somera
Copy link

somera commented Dec 22, 2022

$ gcc -g -O2  -o cmatrix cmatrix.o -lncurses -lncursesw -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 10.3.0-1ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --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-bootstrap --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 --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-10-S4I5Pr/gcc-10-10.3.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-S4I5Pr/gcc-10-10.3.0/debian/tmp-gcn/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-mutex
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.3.0 (Ubuntu 10.3.0-1ubuntu1~20.04)
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-g' '-O2' '-o' 'cmatrix' '-v' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/10/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/10/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper -plugin-opt=-fresolution=/tmp/ccjnMJJu.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 -z now -z relro -o cmatrix /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/10/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/10 -L/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/10/../../../../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/10/../../.. cmatrix.o -lncurses -lncursesw -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/10/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crtn.o
COLLECT_GCC_OPTIONS='-g' '-O2' '-o' 'cmatrix' '-v' '-mtune=generic' '-march=x86-64'

@abishekvashok
Copy link
Owner

Okay and it compiled? Must be a problem with the make file then.

@somera
Copy link

somera commented Dec 22, 2022

Yes.

-rwxrwxr-x 1 rafcio rafcio 64024 Dez 22 17:26 cmatrix

@abishekvashok
Copy link
Owner

Yes yes, will clean the make file.

abishekvashok added a commit that referenced this issue Dec 28, 2022
Fix linker issues that prevent compillation with gcc from succeeding
using autotools.

This allows compilation to succeeed in Mac OS - haven't tested on linux
yet.

Fixes: #161
Signed-off-by: Abishek V Ashok <[email protected]>
@abishekvashok abishekvashok linked a pull request Dec 28, 2022 that will close this issue
@abishekvashok
Copy link
Owner

abishekvashok commented Dec 28, 2022

So, I tried using automake and seems I've fixed compilation issues in automake - but haven't tested it in linux yet - can someone of you help to make sure the patch works in linux as well?

PR: #163

@abishekvashok abishekvashok self-assigned this Dec 28, 2022
@somera
Copy link

somera commented Dec 28, 2022

hm ...

[Mi Dez 28][16:14:28][nuc-mini-pentium]:[/tmp]$ git clone https://github.com/abishekvashok/cmatrix.git
Klone nach 'cmatrix'...
remote: Enumerating objects: 395, done.
remote: Counting objects: 100% (81/81), done.
remote: Compressing objects: 100% (51/51), done.
remote: Total 395 (delta 41), reused 52 (delta 30), pack-reused 314
Empfange Objekte: 100% (395/395), 482.38 KiB | 5.19 MiB/s, fertig.
Löse Unterschiede auf: 100% (209/209), fertig.
[Mi Dez 28][16:14:36][nuc-mini-pentium]:[/tmp]$ cd cmatrix/
[Mi Dez 28][16:14:38][nuc-mini-pentium]:[/tmp/cmatrix]$ git checkout bugfix1
Branch 'bugfix1' folgt nun 'origin/bugfix1'.
Zu neuem Branch 'bugfix1' gewechselt
[Mi Dez 28][16:14:45][nuc-mini-pentium]:[/tmp/cmatrix]$ autoreconf -i && ./configure && make
configure.ac:23: installing './compile'
configure.ac:8: installing './config.guess'
configure.ac:8: installing './config.sub'
configure.ac:6: installing './install-sh'
configure.ac:6: installing './missing'
Makefile.am: installing './depcomp'
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of gcc... gcc3
checking whether make sets $(MAKE)... (cached) yes
checking for main in -lncurses... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking for unistd.h... (cached) yes
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking termio.h usability... yes
checking termio.h presence... yes
checking for termio.h... yes
checking getopt.h usability... yes
checking getopt.h presence... yes
checking for getopt.h... yes
checking return type of signal handlers... void
checking for putenv... yes
checking curses.h usability... yes
checking curses.h presence... yes
checking for curses.h... yes
checking ncurses.h usability... yes
checking ncurses.h presence... yes
checking for ncurses.h... yes
checking for tgetent in -lncurses... yes
"Using ncurses as the termcap library"
checking for use_default_colors in -lncurses... yes
checking for resizeterm in -lncurses... yes
checking for wresize in -lncurses... yes
checking for consolechars... no
checking for setfont... /usr/bin/setfont
checking for /usr/lib/kbd/consolefonts... no
checking for /usr/share/consolefonts... yes
checking for mkfontdir... /usr/bin/mkfontdir
checking for /usr/share/fonts/misc... no
checking for /usr/share/X11/fonts/misc... no
checking for /usr/X11R6/lib/X11/fonts/misc... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating cmatrix.spec
config.status: creating config.h
config.status: executing depfiles commands
make  all-am
make[1]: Entering directory '/tmp/cmatrix'
gcc -DHAVE_CONFIG_H -I.     -g -O2 -MT cmatrix.o -MD -MP -MF .deps/cmatrix.Tpo -c -o cmatrix.o cmatrix.c
mv -f .deps/cmatrix.Tpo .deps/cmatrix.Po
gcc  -g -O2   -o cmatrix cmatrix.o  -lncurses  -lncurses
/usr/bin/ld: cmatrix.o: in function `main':
/tmp/cmatrix/cmatrix.c:850: undefined reference to `waddnwstr'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:427: cmatrix] Error 1
make[1]: Leaving directory '/tmp/cmatrix'
make: *** [Makefile:328: all] Error 2

@abishekvashok
Copy link
Owner

Okay, same error, -lncursesw doesn't work in Mac, so just need to pass it in Linux, let me see.

@somera
Copy link

somera commented Dec 28, 2022

I tested this on Ubuntu 20.04.

@abishekvashok
Copy link
Owner

@somera hey, can you try the latest patch again (added a new commit)? It should add -lncursesw to gcc args if it detects the package in your system and display a warning otherwise if you are on linux.

@somera
Copy link

somera commented Dec 29, 2022

Strange. Now I see this

checking for main in -lncurses... yes
configure: WARNING:

*** ncurses with wide character support is packaged as a seperate library (ncursesw)
*** on some linux distributions such as ubunutu. If you face compilation errors,
*** please install the library.

And than

configure: creating ./config.status
config.status: creating Makefile
config.status: creating cmatrix.spec
config.status: creating config.h
config.status: executing depfiles commands
make  all-am
make[1]: Entering directory '/tmp/cmatrix'
gcc -DHAVE_CONFIG_H -I.     -g -O2 -MT cmatrix.o -MD -MP -MF .deps/cmatrix.Tpo -c -o cmatrix.o cmatrix.c
mv -f .deps/cmatrix.Tpo .deps/cmatrix.Po
gcc  -g -O2   -o cmatrix cmatrix.o  -lncurses  -lcurses
/usr/bin/ld: cmatrix.o: in function `main':
/tmp/cmatrix/cmatrix.c:850: undefined reference to `waddnwstr'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:427: cmatrix] Error 1
make[1]: Leaving directory '/tmp/cmatrix'
make: *** [Makefile:328: all] Error 2

But the needed libs are installed on my system.

This

gcc -g -O2 -o cmatrix cmatrix.o -lncurses -lncursesw -v

is working fine.

@abishekvashok
Copy link
Owner

abishekvashok commented Dec 29, 2022

checking for main in -lncurses... yes
configure: WARNING:

Can you go one line above it?

Also, can you do man waddnstr

@somera
Copy link

somera commented Dec 29, 2022

Sorry, didn't see it first time

$ autoreconf -i && ./configure && make
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of gcc... gcc3
checking whether make sets $(MAKE)... (cached) yes
checking for waddnwstr in -lncursesew... no
checking for main in -lncurses... yes
configure: WARNING:

*** ncurses with wide character support is packaged as a seperate library (ncursesw)
*** on some linux distributions such as ubunutu. If you face compilation errors,
*** please install the library.


checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking for unistd.h... (cached) yes
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking termio.h usability... yes
checking termio.h presence... yes
checking for termio.h... yes
checking getopt.h usability... yes
checking getopt.h presence... yes
checking for getopt.h... yes
checking return type of signal handlers... void
checking for putenv... yes
checking curses.h usability... yes
checking curses.h presence... yes
checking for curses.h... yes
checking ncurses.h usability... yes
checking ncurses.h presence... yes
checking for ncurses.h... yes
checking for tgetent in -lncurses... yes
checking for tgetent in -lcurses... yes
"Using curses as the termcap library"
checking for use_default_colors in -lcurses... yes
checking for resizeterm in -lcurses... yes
checking for wresize in -lcurses... yes
checking for consolechars... no
checking for setfont... /usr/bin/setfont
checking for /usr/lib/kbd/consolefonts... no
checking for /usr/share/consolefonts... yes
checking for mkfontdir... /usr/bin/mkfontdir
checking for /usr/share/fonts/misc... no
checking for /usr/share/X11/fonts/misc... no
checking for /usr/X11R6/lib/X11/fonts/misc... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating cmatrix.spec
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
make  all-am
make[1]: Entering directory '/tmp/cmatrix'
make[1]: Leaving directory '/tmp/cmatrix'

And

$ man waddnstr
No manual entry for waddnstr

@clort81
Copy link

clort81 commented Feb 16, 2023

/usr/bin/ld: cmatrix.o: in function `main':
cmatrix.c:(.text.startup+0x6a8): undefined reference to `waddnwstr'
collect2: error: ld returned 1 exit status

SYSTEM: devuan ceres linux, aarch64.
Package: libncurses6
Version: 6.4-2
Package: libncurses5
Version: 6.4-2

$ grep -ri waddnstr /usr/include
/usr/include/cursesw.h:#ifdef mvwaddnstr
/usr/include/cursesw.h:inline int UNDEF(mvwaddnstr)(WINDOW *win, int y, int x, const char *str, int n)
/usr/include/cursesw.h:{ return mvwaddnstr(win, y, x, str, n); }
/usr/include/cursesw.h:#undef mvwaddnstr
/usr/include/cursesw.h:#define mvwaddnstr UNDEF(mvwaddnstr)
/usr/include/cursesw.h:    return ::waddnstr(w, str, n); }
/usr/include/cursesw.h:    return ::mvwaddnstr(w, y, x, str, n); }
/usr/include/curses.h:extern NCURSES_EXPORT(int) mvwaddnstr (WINDOW *, int, int, const char *, int);    /* generated */
/usr/include/curses.h:extern NCURSES_EXPORT(int) waddnstr (WINDOW *,const char *,int);  /* implemented */
/usr/include/curses.h:#define waddstr(win,str)  waddnstr(win,str,-1)
/usr/include/curses.h:#define addnstr(str,n)            waddnstr(stdscr,(str),(n))
/usr/include/curses.h:#define addstr(str)               waddnstr(stdscr,(str),-1)
/usr/include/curses.h:#define mvwaddnstr(win,y,x,str,n) (wmove((win),(y),(x)) == ERR ? ERR : waddnstr((win),(str),(n)))
/usr/include/curses.h:#define mvwaddstr(win,y,x,str)            (wmove((win),(y),(x)) == ERR ? ERR : waddnstr((win),(str),-1))
/usr/include/curses.h:#define mvaddnstr(y,x,str,n)              mvwaddnstr(stdscr,(y),(x),(str),(n))
/usr/include/slcurses.h:extern int SLcurses_waddnstr (SLcurses_Window_Type *, char *, int);
/usr/include/slcurses.h:#define waddnstr                SLcurses_waddnstr
/usr/include/slcurses.h:#define waddstr(w,s)            waddnstr((w),(s),-1)
/usr/include/slcurses.h:#define addnstr(s,n)            waddnstr(stdscr,(s),(n))
/usr/include/slcurses.h:#define mvwaddnstr(w,y,x,s,n) \
/usr/include/slcurses.h:  (-1 == wmove((w),(y),(x)) ? -1 : waddnstr((w),(s),(n)))
/usr/include/slcurses.h:  (-1 == wmove((w),(y),(x)) ? -1 : waddnstr((w),(s), -1))
/usr/include/slcurses.h:#define mvaddnstr(y,x,s,n)      mvwaddnstr(stdscr,(y),(x),(s),(n))

Missing function is in ncursesw.h
Happens with configure+make as well as with cmake ..

(the old cmatrix 1.2a builds fine.)

gcc -g -O2 -o cmatrix cmatrix.o -lncurses -lncursesw -v

gives an executeable as this links ncursesw.

maybe seperate issue:

running that gives Segmentation fault when first string hits bottom of terminal. (xterm)

gdb output

                                                                                                                                  Program received signal SIGSEGV, Segmentation fault.
                                                  0x0000fffff7f171e4 in ?? () from /lib/aarch64-linux-gnu/libtinfo.so.6
(gdb) bt
#0  0x0000fffff7f171e4 in ?? () from /lib/aarch64-linux-gnu/libtinfo.so.6
#1  0x0000fffff7de56ec in __GI___tfind (key=0xffffffffe9d0, vrootp=<optimized out>, compar=0xfffff7f171e0) at ./misc/tsearch.c:387
#2  0x0000fffff7f178bc in ?? () from /lib/aarch64-linux-gnu/libtinfo.so.6
#3  0x0000fffff7f1a5d4 in _nc_tiparm () from /lib/aarch64-linux-gnu/libtinfo.so.6
#4  0x0000fffff7f60e20 in ?? () from /lib/aarch64-linux-gnu/libncurses.so.6
#5  0x0000fffff7f61474 in ?? () from /lib/aarch64-linux-gnu/libncurses.so.6
#6  0x0000fffff7f61eec in ?? () from /lib/aarch64-linux-gnu/libncurses.so.6
#7  0x0000fffff7f6bf8c in ?? () from /lib/aarch64-linux-gnu/libncurses.so.6
#8  0x0000fffff7f6ccb4 in doupdate_sp () from /lib/aarch64-linux-gnu/libncurses.so.6
#9  0x0000fffff7f63c44 in wrefresh () from /lib/aarch64-linux-gnu/libncurses.so.6
#10 0x0000fffff7f5e190 in ?? () from /lib/aarch64-linux-gnu/libncurses.so.6
#11 0x0000fffff7f5e540 in wgetch () from /lib/aarch64-linux-gnu/libncurses.so.6
#12 0x0000aaaaaaaa1b40 in main ()
(gdb) 

fun program. might consider ditching curses dino entirely in favor of
https://github.com/tomsmeding/termio

Since nobody needs ncurses terminal abstraction (termcap) unless they're running a 1970s-80s hardware serial terminal. It's all ansi/vt100 controls today. Only the wildest edge cases are not. Only difference you'll find in practice is #colors supported.

@maskimko
Copy link

I solved this build issue with 2 simple things:

  • First I noticed that on my Amazon Linux 2, ncurses header file is called curses.h but not ncurses.h So I just id this change
diff --git a/cmatrix.c b/cmatrix.c
index 7d8ca39..d609573 100644
--- a/cmatrix.c
+++ b/cmatrix.c
@@ -48,7 +48,7 @@
 #endif

 #ifdef HAVE_NCURSES_H
-#include <ncurses.h>
+#include <curses.h>
 #else
 #ifdef _WIN32
 #include <ncurses/curses.h>
  • second I added -lncursesw to the LIBS variable of makefile line 217 of Makefile: LIBS = -lncurses -lncursesw
  • Third just make && make install

@skytwosea
Copy link

I had the same issue, and resolved it as per @maskimko's post; make and make install worked and cmatrix runs. However, as soon as the first text rain hits the base of my terminal, I get a segmentation fault.
kubuntu 5.15.0, using Konsole

@chi-lambda
Copy link

It works mostly fine for me with Debian Bullseye if I only specify -lncursesw, but not -lncurses. However, option -c (which, despite what the man page says, merely changes the output to Japanese) outputs both Japanese characters in the odd columns and ASCII characters in the even columns, with performance degrading dramatically once the screen is about 70% filled:

image

Lambda mode (option -m) is fine.

@Maxito7
Copy link

Maxito7 commented Jul 3, 2023

image

I myself am getting this error after trying @maskimko's solution. Not really sure why it's not creating anything, though I'm at least no longer getting that waddnstr error.

Even weirder, the command works but it prints out this:
image

May very well be a font/terminal issue, but overall very weird

SkyperTHC added a commit to SkyperTHC/cmatrix that referenced this issue Sep 11, 2023
@akashi979
Copy link

Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-1160.95.1.el7.x86_64
Architecture: x86-64

make all-am
make[1]: Entering directory /home/akash/cmatrix' gcc -g -O2 -o cmatrix cmatrix.o -lncurses -lncurses cmatrix.o: In function main':
/home/akash/cmatrix/cmatrix.c:850: undefined reference to waddnwstr' collect2: error: ld returned 1 exit status make[1]: *** [cmatrix] Error 1 make[1]: Leaving directory /home/akash/cmatrix'
make: *** [all] Error 2

getting the above error

@justinvforvendetta
Copy link

@Maxito7 your error is because you used sudo make, and no sudo after with the 'make install', so permission for make to install (move the bin) without sudo was denied

@justinvforvendetta
Copy link

also, i do get the waddnwstr error on WSL Ubuntu 22, and definitelyu have the lib.. only solution that worked was downloading the tar.

@stemid
Copy link

stemid commented Oct 25, 2023

I'm going to borrow this thread because I get the same ncurses error, but I also cannot get it working at all on Fedora 38.

It does eventually compile with this command that @abishekvashok showed; gcc -g -O2 -o cmatrix cmatrix.o -lncurses -lncursesw -v but the binary segfaults as soon as the first character reaches the bottom of the terminal. I tried this only in gnome-terminal and tmux in gnome-terminal.

[stemid@toolbox cmatrix](508/0/master)$ gcc -g -O2  -o cmatrix cmatrix.o -lncurses -lncursesw -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/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='Ubuntu 11.4.0-1ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --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-bootstrap --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-11-XeT9lY/gcc-11-11.4.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-XeT9lY/gcc-11-11.4.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04) 
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/11/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/11/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-g' '-O2' '-o' 'cmatrix' '-v' '-mtune=generic' '-march=x86-64' '-dumpdir' 'cmatrix.'
 /usr/lib/gcc/x86_64-linux-gnu/11/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/11/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper -plugin-opt=-fresolution=/tmp/ccJNZazi.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 -z now -z relro -o cmatrix /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/11/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/11 -L/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/11/../../../../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/11/../../.. cmatrix.o -lncurses -lncursesw -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/11/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/crtn.o
COLLECT_GCC_OPTIONS='-g' '-O2' '-o' 'cmatrix' '-v' '-mtune=generic' '-march=x86-64' '-dumpdir' 'cmatrix.'

I also tried building it in an Ubuntu 23.10 Toolbx container, same build error.

[stemid@toolbox cmatrix](511/0/master)$ ldconfig -p | grep ncurses
        libncursesw.so.6 (libc6,x86-64) => /lib/x86_64-linux-gnu/libncursesw.so.6
        libncurses.so.6 (libc6,x86-64) => /lib/x86_64-linux-gnu/libncurses.so.6
[stemid@toolbox cmatrix](509/0/master)$ ./configure --bindir=$HOME/.local/bin
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk   
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for gcc... gcc       
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...                                                 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of gcc... gcc3                                              
checking whether make sets $(MAKE)... (cached) yes
checking for main in -lncurses... yes
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fcntl.h... yes
checking for sys/ioctl.h... yes
checking for unistd.h... (cached) yes
checking for termios.h... yes
checking for termio.h... yes
checking for getopt.h... yes
checking return type of signal handlers... void
checking for putenv... yes
checking for curses.h... yes
checking for ncurses.h... yes
checking for tgetent in -lncurses... yes
"Using ncurses as the termcap library"
checking for use_default_colors in -lncurses... yes
checking for resizeterm in -lncurses... yes
checking for wresize in -lncurses... yes
checking for consolechars... no
checking for setfont... /usr/bin/setfont
checking for /usr/lib/kbd/consolefonts... no
checking for /usr/share/consolefonts... yes
checking for mkfontdir... no
checking for /usr/share/fonts/misc... no
checking for /usr/share/X11/fonts/misc... no
checking for /usr/X11R6/lib/X11/fonts/misc... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating cmatrix.spec
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
[stemid@toolbox cmatrix](510/0/master)$ make
make  all-am
make[1]: Entering directory '/var/home/stemid/src/cmatrix'
gcc -DHAVE_CONFIG_H -I.     -g -O2 -MT cmatrix.o -MD -MP -MF .deps/cmatrix.Tpo -c -o cmatrix.o cmatrix.c
mv -f .deps/cmatrix.Tpo .deps/cmatrix.Po
gcc  -g -O2   -o cmatrix cmatrix.o  -lncurses  -lncurses
/usr/bin/ld: cmatrix.o: in function `main':
/var/home/stemid/src/cmatrix/cmatrix.c:850: undefined reference to `waddnwstr'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:428: cmatrix] Error 1
make[1]: Leaving directory '/var/home/stemid/src/cmatrix'
make: *** [Makefile:329: all] Error 2

@kesavanm
Copy link

Failed with make install but gcc -g -O2 -o cmatrix cmatrix.o -lncurses -lncursesw -v made it.

-lncursesw -v is the key!

OS Info:

$cat /etc/os-release 
PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

Error:
/home/ubuntu/cmatrix/cmatrix.c:850: undefined reference to 'waddnwstr'

Screenshot at 2024-01-28 22:03:35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.