Hi folks,

This is probably a PEBKAC, but I'm mystified.

When I try to build an application against the ncursestw configuration,
I get symbol visibility problems from the compiler and linker:

cc -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 
-I/home/branden/ncurses-HEAD/include/ncursestw 
-I/home/branden/ncurses-HEAD/include wresize.c -o wresize 
-L/home/branden/ncurses-HEAD/lib -lncursestw -ltinfotw -ldb -lpthread
wresize.c: In function ‘main’:
wresize.c:40:6: warning: implicit declaration of function ‘is_cbreak’; did you 
mean ‘nocbreak’? [-Wimplicit-function-declaration]
   40 |  if (is_cbreak())
      |      ^~~~~~~~~
      |      nocbreak
wresize.c:42:6: warning: implicit declaration of function ‘is_echo’ 
[-Wimplicit-function-declaration]
   42 |  if (is_echo())
      |      ^~~~~~~
wresize.c:44:6: warning: implicit declaration of function ‘is_nl’ 
[-Wimplicit-function-declaration]
   44 |  if (is_nl())
      |      ^~~~~
wresize.c:46:6: warning: implicit declaration of function ‘is_raw’; did you 
mean ‘is_pad’? [-Wimplicit-function-declaration]
   46 |  if (is_raw())
      |      ^~~~~~
      |      is_pad
/usr/bin/ld: /tmp/branden/ccmndyyU.o: warning: relocation against `stdscr' in 
read-only section `.text'
/usr/bin/ld: /tmp/branden/ccmndyyU.o: in function `main':
wresize.c:(.text+0x35): undefined reference to `stdscr'
/usr/bin/ld: wresize.c:(.text+0x49): undefined reference to `stdscr'
/usr/bin/ld: wresize.c:(.text+0x70): undefined reference to `stdscr'
/usr/bin/ld: wresize.c:(.text+0x99): undefined reference to `stdscr'
/usr/bin/ld: wresize.c:(.text+0xc2): undefined reference to `stdscr'
/usr/bin/ld: /tmp/branden/ccmndyyU.o:wresize.c:(.text+0xeb): more undefined 
references to `stdscr' follow
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
make: *** [Makefile:39: wresize] Error 1

I'm attaching:

1.  the wresize.c source file;
2.  my Makefile;
3.  the script I used to build ncurses; and
4.  the script I used to configure curses.

Any ideas?

Regards,
Branden
#include <locale.h> // setlocale()
#include <stdlib.h> // calloc()

#include <ncursesw/curses.h>

#ifndef NCURSES_VERSION
#error this is not ncurses
#endif

#ifndef NCURSES_OPAQUE
#error this ncurses is not opaque
#endif

/*
 * How do cbreak, echo, and nl interact?
 *
 *                              move to BOL	move to next line
 * nocbreak, noecho, nonl	Enter, ^J, ^M
 * nocbreak, noecho, nl		Enter, ^J, ^M
 * nocbreak, echo, nonl		Enter, ^J, ^M
 * nocbreak, echo, nl		Enter, ^J, ^M
 *
 * cbreak, noecho, nonl		nothing
 * cbreak, noecho, nl		nothing
 * cbreak, echo, nonl		^J
 * cbreak, echo, nl		^J
 */

int main(void) {
	setlocale(LC_ALL, "");
	initscr();
	cbreak();
	echo();
	nonl();
	noqiflush();
	keypad(stdscr, TRUE);

	move(0, 0);

	if (is_cbreak())
		addwstr(L"cbreak\n");
	if (is_echo())
		addwstr(L"echo\n");
	if (is_nl())
		addwstr(L"nl\n");
	if (is_raw())
		addwstr(L"raw\n");

	addwstr(L"Press Enter, ^J, and/or ^M.");
	refresh();

	int ret;
	wchar_t *buf;
	wint_t wch;

	while (TRUE) {
		ret = get_wch(&wch);
		if (OK == ret) {
			buf = calloc(1, BUFSIZ);
			if (buf != NULL)
				ret = swprintf(buf, (BUFSIZ - 1),
					       L" (%d) ", wch);
				(void) addwstr(buf);
				if ('\n' == wch)
					addwstr(L"Newline.  ");
				if ('\r' == wch)
					addwstr(L"Carriage return.  ");
		}
		else if (KEY_CODE_YES == ret) {
			addstr(keyname(wch));
			addch(' ');
		}
		refresh();
		(void) napms(50);
	}

	endwin();
}
NBINDIR:=$(HOME)/ncurses-HEAD/bin

# These find Debian's old ncurses headers and libraries--not what I
# want.
#CFLAGS:=$(shell ncurses6-config --cflags)
#LDFLAGS:=$(shell ncurses6-config --libs)

#CFLAGS:=$(shell $(NBINDIR)/ncursesw6-config --cflags)
#LDFLAGS:=$(shell $(NBINDIR)/ncursesw6-config --libs)

CFLAGS:=$(shell $(NBINDIR)/ncursestw6-config --cflags)
LDFLAGS:=$(shell $(NBINDIR)/ncursestw6-config --libs)

ALL:=has_mouse hello_mouse hello_narrow hello_wide insch insch2 nl nl2 \
        simple termcap waddch wresize wsimple getyx termsize wunctrl \
        define-key cooked instr inwstr innwstr getstr getstr-left-edge \
        getstr_bottom_right \
        get_wstr \
        scroll \
        bkgd_uninitialized bkgd bkgrnd_uninitialized bkgrnd \
        addch_uninitialized addch addch_at_bottom_right \
        addch_at_bottom_right_without_idcok \
        add_wch_uninitialized add_wch \
        addchstr \
        addstr \
        addwstr_bottom_right \
        scroll morescroll has_colors wtimeout notimeout isendwin_early \
        isendwin ripoffline \
        attributes \
        getch_cooked getch_cbreak_no_keypad getch_cbreak_keypad \
        move_without_init

all: $(ALL)

clean:
        $(RM) $(ALL)

%: %.c
        $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)

Attachment: remake-ncurses.sh
Description: remake-ncurses.sh

#!/bin/sh

# autoreconf-dickey -f -i

./configure \
        --prefix=$HOME/ncurses-HEAD \
        --with-shared \
        --with-cxx-shared \
        --with-hashed-db \
        --with-manpage-format=normal \
        --with-pthread \
        --with-termlib \
        --with-versioned-syms \
        --enable-opaque-curses \
        --enable-opaque-form \
        --enable-opaque-menu \
        --enable-opaque-panel \

#       --enable-widec \
#       --disable-widec \

#       --with-shlib-version=rel \
#       --with-ada-sharedlib \ "no GNAT project support"
#       --with-config-suffix=GBRINFIX \

#       --with-trace \

#       --enable-pc-files \
#       --with-pkg-config \
#       --with-pc-suffix=GBRSUFFIX \

Attachment: signature.asc
Description: PGP signature

Reply via email to