Problem
I cannot compile and link a termcap curses program in SCO OpenServer
Release 5. When I try to build my application with a command such
as 'cc myapp.c -o myapp -ltcap -ltermlib', I get the error:i386ld myapp.o: can't find library libtcap.a Cause
The termcap library, /usr/lib/libtcap.a, is not furnished with the SCO OpenServer Release 5 development systems.
Solution
In the SCO OpenServer Release 5 operating systems, the building of
termcap curses applications is _unsupported_. However, it may
still be possible to build a termcap curses application on SCO
OpenServer Release 5. In order to do so, you must copy the file
/usr/lib/libtcap.a from an SCO Open Desktop 3.0 or SCO UNIX Version
4.2 system to your OpenServer Release 5 system, and use the compile
options indicated in the source comments in the example below.The following program provides a working example of a simple curses application that may be compiled with either termcap or terminfo, and on either SCO UNIX Version 4.2-based systems, or on SCO OpenServer Release 5, once the aforementioned file is copied. This example demonstrates how to read the function keys using curses:
/*********cut here************//* * Demonstration of how to read the function keys with termcap/terminfo curses. * * To compile on OpenServer Release 5: * cc file.c -DM_TERMCAP -ltcap -ltermlib To compile with termcap curses * cc file.c -lcurses To compile with terminfo curses * * To compile on ODT 3.0 or Unix 4.2: * cc file.c _DM_TERMCAP -lcurses To compile with termcap curses * cc file.c -lcurses To compile with terminfo curses * Note: program only generically works for F1-F10 */
#include <curses.h>
#include <signal.h>
#ifdef M_TERMCAP
#include <tcap.h>
#endifmain() { char * getenv(); int die(); int ch;
signal(SIGINT, die); /* die gracefully if DEL key pressed */
initscr(); /* initialize screen processing */
keypad(stdscr, TRUE); /* enable function and keypad keys mapping */
scrollok(stdscr, TRUE); /* allow terminal to scroll */
noecho();
addstr("Type 'q' to quit\n\n");
refresh();for(;;)
{
ch = wgetch(stdscr); /* wait for a key */if (ch == 'q') break; if ( ch >= KEY_F0 ) printw("Function key pressed was %d\n", (ch - KEY_F(0)) ? (ch - KEY_F(0)) : 10); else printw("character was '%c'\n", ch); refresh(); } die(); }
int die() {
endwin(); /* restore the terminal */
exit(0);
}/***************cut here****************/ See also
For similar examples and information on reading function keys in older SCO legacy products, see:
ta100892, "How to read the function keys in terminfo curses."
ta100878, "Keypad() maps function key 10 incorrectly using terminfo curses on the console."