[GRASS5] Using 'vask' library

Hi GRASS developers,

I have to compile a program that runs under grass using, among other things,
the 'vask' library. It compiles, but gives the following error when run:

GRASS:~ > swatgrass
'xterm-xfree86': unknown terminal type.
Error opening terminal: xterm-xfree86.
GRASS:~ >

I've determined that this message is generated when V_call() is called.
Curiously, when I run the program in gdb, it runs ok and the screen menus are
displayed just fine!

I thought maybe the problem has to do with how I linked in the termcap
library. Programmer's manual suggests using $(VASK), because "it specifies
both the UNIX curses and termcap libraries as well as $(VASKLIB)" (p. 286),
however, $(VASK) is not set when I ran 'gmake5' on the GMakefile (see below).
So I just plugged the libraries directly:
  $(CC) $(LDFLAGS) -o $@ $(LIST) -ltermcap -lcurses $(LIBES)

Below is the whole GMakefile. I'd be very glad to hear any ideas...

Thank you,

Aleksey

-------------- GMakefile --------------------------------
LIBES = $(D_LIB) $(DISPLAYLIB) $(RASTERLIB) $(GISLIB) $(VASKLIB) $(MATHLIB)
$(DATETIMELIB) $(ZLIB)

#EXTRA_CFLAGS = -DDEBUG -DBOBMGT -DLB_LUSE_SOIL -DHUMUS -DVERELMGT -DQUAL2E
-L/usr/lib

PGM = swatgrs

LIST = \
  dummy_lcra.o\
  ... more object files here ...
        main.o

./$(PGM): $(LIST) $(LIBES)
    @echo VASK = $(VASK)
    @echo VASKLIB = $(VASKLIB)
    @echo DATETIMELIB = $(DATETIMELIB)
    @echo ZLIB = $(ZLIB)
    @echo
    $(CC) $(LDFLAGS) -o $@ $(LIST) -ltermcap -lcurses $(LIBES)

$(LIBES): #

Aleksey Naumov wrote:

I have to compile a program that runs under grass using, among other things,
the 'vask' library. It compiles, but gives the following error when run:

GRASS:~ > swatgrass
'xterm-xfree86': unknown terminal type.
Error opening terminal: xterm-xfree86.
GRASS:~ >

This is generated by curses (or, more precisely, by the termcap or
terminfo functions which curses calls).

I've determined that this message is generated when V_call() is
called.

It's probably generated by the call to initscr() within V_init(),
although the call to system("clear") may also generate the error
(although I suspect not).

Curiously, when I run the program in gdb, it runs ok and the screen menus are
displayed just fine!

I thought maybe the problem has to do with how I linked in the termcap
library. Programmer's manual suggests using $(VASK), because "it specifies
both the UNIX curses and termcap libraries as well as $(VASKLIB)" (p. 286),
however, $(VASK) is not set when I ran 'gmake5' on the GMakefile (see below).

The documentation is incorrect; the correct invocation for linking
against the Vask library is "$(VASKLIB) $(CURSES)".

So I just plugged the libraries directly:
  $(CC) $(LDFLAGS) -o $@ $(LIST) -ltermcap -lcurses $(LIBES)

This is probably incorrect.

Most modern curses libraries use terminfo, not termcap. Also, the
terminfo functions are typically built into the curses library rather
than being a separate library.

On GNU-based systems, it's common for both libtermcap and libncurses
(libcurses.so is normally a symlink to libncurses.so) to define
symbols such as tgetent(). However, the version in libncurses will
typically use terminfo, while the version in libcurses uses termcap.

What I suspect is happening is that terminfo has a definition for
xterm-xfree86, while termcap doesn't.

I suggest using $(CURSES); that should contain the correct switch for
the curses library (either -lcurses or -lncurses), plus any necessary
dependencies (which may include termcap/terminfo libraries, and
possibly a BSD compatibility library for gtty()).

--
Glynn Clements <glynn.clements@virgin.net>

On Tue, Feb 12, 2002 at 12:07:10AM +0000, Glynn Clements wrote:

Aleksey Naumov wrote:

> I have to compile a program that runs under grass using, among other things,
> the 'vask' library. It compiles, but gives the following error when run:
>
> GRASS:~ > swatgrass
> 'xterm-xfree86': unknown terminal type.
> Error opening terminal: xterm-xfree86.
> GRASS:~ >

This is generated by curses (or, more precisely, by the termcap or
terminfo functions which curses calls).

> I've determined that this message is generated when V_call() is
> called.

It's probably generated by the call to initscr() within V_init(),
although the call to system("clear") may also generate the error
(although I suspect not).

> Curiously, when I run the program in gdb, it runs ok and the screen menus are
> displayed just fine!
>
> I thought maybe the problem has to do with how I linked in the termcap
> library. Programmer's manual suggests using $(VASK), because "it specifies
> both the UNIX curses and termcap libraries as well as $(VASKLIB)" (p. 286),
> however, $(VASK) is not set when I ran 'gmake5' on the GMakefile (see below).

The documentation is incorrect; the correct invocation for linking
against the Vask library is "$(VASKLIB) $(CURSES)".

Hi,

I have changed the old passage:
\textbf{Note.} The target \textit{pgm} depends on the object files \$(OBJ)
and the \textit{Vask Library} \$(VASKLIB). This is done so that
modifications to any of the \$(OBJ) files or to the \$(VASKLIB) itself will
force module reloading. However, the compile rule specifies \$(OBJ) and
\$(VASK), rather than \$(OBJ) and \$(VASKLIB). This is because \$(VASK)
specifies both the UNIX curses and termcap libraries as well as \$(VASKLIB).

to (new):

\textbf{Note.} The target \textit{pgm} depends on the object files \$(OBJ)
and the \textit{Vask Library} \$(VASKLIB). This is done so that
modifications to any of the \$(OBJ) files or to the \$(VASKLIB) itself will
force module reloading. Linking against the Vask library is \$(VASKLIB)
\$(CURSES), it specifies both the UNIX curses and termcap/terminfo libraries
as well as \$(VASKLIB).

[sorry for the Latex markup]
Does this change make sense? If not, please correct, then I publish the
updated PDF.

Thanks,

Markus

Markus Neteler wrote:

I have changed the old passage:

[snip]

to (new):

\textbf{Note.} The target \textit{pgm} depends on the object files \$(OBJ)
and the \textit{Vask Library} \$(VASKLIB). This is done so that
modifications to any of the \$(OBJ) files or to the \$(VASKLIB) itself will
force module reloading. Linking against the Vask library is \$(VASKLIB)
\$(CURSES), it specifies both the UNIX curses and termcap/terminfo libraries
as well as \$(VASKLIB).

[sorry for the Latex markup]
Does this change make sense? If not, please correct, then I publish the
updated PDF.

The phrase "Linking against the Vask library is \$(VASKLIB) \$(CURSES)"
isn't grammatically correct. It should probably say something like
"Linking against the Vask library is performed using \$(VASKLIB) \$(CURSES)"

Apart from that, it's OK.

--
Glynn Clements <glynn.clements@virgin.net>

On Tue, Feb 12, 2002 at 07:42:06AM +0000, Glynn Clements wrote:

Markus Neteler wrote:

> I have changed the old passage:

[snip]

> to (new):
>
> \textbf{Note.} The target \textit{pgm} depends on the object files \$(OBJ)
> and the \textit{Vask Library} \$(VASKLIB). This is done so that
> modifications to any of the \$(OBJ) files or to the \$(VASKLIB) itself will
> force module reloading. Linking against the Vask library is \$(VASKLIB)
> \$(CURSES), it specifies both the UNIX curses and termcap/terminfo libraries
> as well as \$(VASKLIB).
>
> [sorry for the Latex markup]
> Does this change make sense? If not, please correct, then I publish the
> updated PDF.

The phrase "Linking against the Vask library is \$(VASKLIB) \$(CURSES)"
isn't grammatically correct. It should probably say something like
"Linking against the Vask library is performed using \$(VASKLIB) \$(CURSES)"

Apart from that, it's OK.

Thanks. The updated PDF is posted on the web site.

Markus

Glynn, thank you for the very detailed explanation, it was right on target!
The program works ok now, once it was linked against $(CURSES).

Markus, thanks for updating the docs!

Aleksey

hit the problem right on

On Tuesday 12 February 2002 02:42, Glynn Clements wrote:

Markus Neteler wrote:
> I have changed the old passage:

[snip]

> to (new):
>
> \textbf{Note.} The target \textit{pgm} depends on the object files
> \$(OBJ) and the \textit{Vask Library} \$(VASKLIB). This is done so that
> modifications to any of the \$(OBJ) files or to the \$(VASKLIB) itself
> will force module reloading. Linking against the Vask library is
> \$(VASKLIB) \$(CURSES), it specifies both the UNIX curses and
> termcap/terminfo libraries as well as \$(VASKLIB).
>
> [sorry for the Latex markup]
> Does this change make sense? If not, please correct, then I publish the
> updated PDF.

The phrase "Linking against the Vask library is \$(VASKLIB) \$(CURSES)"
isn't grammatically correct. It should probably say something like
"Linking against the Vask library is performed using \$(VASKLIB)
\$(CURSES)"

Apart from that, it's OK.