monkeyboi
09-13-2002, 03:41 AM
i try to compile this C code and it always give me errors
here is the code:
---------------------------
#include <stdio.h>
#include <stdarg.h>
#include <curses.h>
#define max_string 1024
static struct {
WINDOW *mainwin;
WINDOW *text;
WINDOW *cmd;
} mw;
static void initialize (void);
static void printwin (const char *fmt, ...);
void main ()
{
char buf[128];
initialize ();
while (1) {
wgetnstr (mw.cmd, buf, sizeof (buf));
printwin ("%s\n", buf);
}
}
static void printwin (const char *fmt, ...)
{
static int cur_line;
va_list ap;
char buf[max_string];
memset (buf, 0, sizeof (buf));
va_start (ap, fmt);
vsnprintf (buf, max_string, fmt, ap);
va_end (ap);
wprintw (mw.text, buf);
wrefresh (mw.text);
wclear (mw.cmd);
wrefresh (mw.cmd);
cur_line++;
if (cur_line==22) {
scroll(mw.text);
cur_line=0;
}
}
static void initialize (void)
{
initscr ();
cbreak ();
if (LINES < 5 || COLS < 10) {
fprintf (stderr, "no way\n");
exit (1);
}
mw.mainwin = newwin (LINES - 1, 0, 0, 0);
mw.text = newwin (LINES - 3, COLS - 2, 1, 1);
mw.cmd = newwin (1, 0, LINES - 1, 0);
scrollok(mw.text, TRUE);
box (mw.mainwin, ACS_VLINE, ACS_HLINE);
wrefresh (stdscr);
wrefresh (mw.mainwin);
wrefresh (mw.text);
wrefresh (mw.cmd);
doupdate ();
}
------------------
this is the command i use to compile
gcc curses-test.c -o curses-test -lncurse
i also tried
gcc curses-test.c -o curses-test -lcurse
and here is the errors i got
---------------------
ncurses-test.c: In function `main':
ncurses-test.c:17: warning: return type of `main' is not `int'
/tmp/ccSwWkgx.o: In function `main':
/tmp/ccSwWkgx.o(.text+0x27): undefined reference to `wgetnstr'
/tmp/ccSwWkgx.o: In function `printwin':
/tmp/ccSwWkgx.o(.text+0x9d): undefined reference to `wprintw'
/tmp/ccSwWkgx.o(.text+0xae): undefined reference to `wrefresh'
/tmp/ccSwWkgx.o(.text+0xbf): undefined reference to `wclear'
/tmp/ccSwWkgx.o(.text+0xd0): undefined reference to `wrefresh'
/tmp/ccSwWkgx.o(.text+0xf2): undefined reference to `wscrl'
/tmp/ccSwWkgx.o: In function `initialize':
/tmp/ccSwWkgx.o(.text+0x10f): undefined reference to `initscr'
/tmp/ccSwWkgx.o(.text+0x114): undefined reference to `cbreak'
/tmp/ccSwWkgx.o(.text+0x11a): undefined reference to `LINES'
/tmp/ccSwWkgx.o(.text+0x123): undefined reference to `COLS'
/tmp/ccSwWkgx.o(.text+0x15a): undefined reference to `LINES'
/tmp/ccSwWkgx.o(.text+0x161): undefined reference to `newwin'
/tmp/ccSwWkgx.o(.text+0x174): undefined reference to `COLS'
/tmp/ccSwWkgx.o(.text+0x17d): undefined reference to `LINES'
/tmp/ccSwWkgx.o(.text+0x186): undefined reference to `newwin'
/tmp/ccSwWkgx.o(.text+0x197): undefined reference to `LINES'
/tmp/ccSwWkgx.o(.text+0x1a2): undefined reference to `newwin'
/tmp/ccSwWkgx.o(.text+0x1bc): undefined reference to `scrollok'
/tmp/ccSwWkgx.o(.text+0x1cf): undefined reference to `acs_map'
/tmp/ccSwWkgx.o(.text+0x1d5): undefined reference to `acs_map'
/tmp/ccSwWkgx.o(.text+0x1db): undefined reference to `acs_map'
/tmp/ccSwWkgx.o(.text+0x1e1): undefined reference to `acs_map'
/tmp/ccSwWkgx.o(.text+0x1ed): undefined reference to `wborder'
/tmp/ccSwWkgx.o(.text+0x1f8): undefined reference to `stdscr'
/tmp/ccSwWkgx.o(.text+0x1fe): undefined reference to `wrefresh'
/tmp/ccSwWkgx.o(.text+0x20f): undefined reference to `wrefresh'
/tmp/ccSwWkgx.o(.text+0x220): undefined reference to `wrefresh'
/tmp/ccSwWkgx.o(.text+0x231): undefined reference to `wrefresh'
/tmp/ccSwWkgx.o(.text+0x239): undefined reference to `doupdate'
collect2: ld returned 1 exit status
-------------
and yes i got my ncurses and curses library installed... i did it like 5 times using slackware ugradepkg....
btw i run slackware 8.1
thx in advance
here is the code:
---------------------------
#include <stdio.h>
#include <stdarg.h>
#include <curses.h>
#define max_string 1024
static struct {
WINDOW *mainwin;
WINDOW *text;
WINDOW *cmd;
} mw;
static void initialize (void);
static void printwin (const char *fmt, ...);
void main ()
{
char buf[128];
initialize ();
while (1) {
wgetnstr (mw.cmd, buf, sizeof (buf));
printwin ("%s\n", buf);
}
}
static void printwin (const char *fmt, ...)
{
static int cur_line;
va_list ap;
char buf[max_string];
memset (buf, 0, sizeof (buf));
va_start (ap, fmt);
vsnprintf (buf, max_string, fmt, ap);
va_end (ap);
wprintw (mw.text, buf);
wrefresh (mw.text);
wclear (mw.cmd);
wrefresh (mw.cmd);
cur_line++;
if (cur_line==22) {
scroll(mw.text);
cur_line=0;
}
}
static void initialize (void)
{
initscr ();
cbreak ();
if (LINES < 5 || COLS < 10) {
fprintf (stderr, "no way\n");
exit (1);
}
mw.mainwin = newwin (LINES - 1, 0, 0, 0);
mw.text = newwin (LINES - 3, COLS - 2, 1, 1);
mw.cmd = newwin (1, 0, LINES - 1, 0);
scrollok(mw.text, TRUE);
box (mw.mainwin, ACS_VLINE, ACS_HLINE);
wrefresh (stdscr);
wrefresh (mw.mainwin);
wrefresh (mw.text);
wrefresh (mw.cmd);
doupdate ();
}
------------------
this is the command i use to compile
gcc curses-test.c -o curses-test -lncurse
i also tried
gcc curses-test.c -o curses-test -lcurse
and here is the errors i got
---------------------
ncurses-test.c: In function `main':
ncurses-test.c:17: warning: return type of `main' is not `int'
/tmp/ccSwWkgx.o: In function `main':
/tmp/ccSwWkgx.o(.text+0x27): undefined reference to `wgetnstr'
/tmp/ccSwWkgx.o: In function `printwin':
/tmp/ccSwWkgx.o(.text+0x9d): undefined reference to `wprintw'
/tmp/ccSwWkgx.o(.text+0xae): undefined reference to `wrefresh'
/tmp/ccSwWkgx.o(.text+0xbf): undefined reference to `wclear'
/tmp/ccSwWkgx.o(.text+0xd0): undefined reference to `wrefresh'
/tmp/ccSwWkgx.o(.text+0xf2): undefined reference to `wscrl'
/tmp/ccSwWkgx.o: In function `initialize':
/tmp/ccSwWkgx.o(.text+0x10f): undefined reference to `initscr'
/tmp/ccSwWkgx.o(.text+0x114): undefined reference to `cbreak'
/tmp/ccSwWkgx.o(.text+0x11a): undefined reference to `LINES'
/tmp/ccSwWkgx.o(.text+0x123): undefined reference to `COLS'
/tmp/ccSwWkgx.o(.text+0x15a): undefined reference to `LINES'
/tmp/ccSwWkgx.o(.text+0x161): undefined reference to `newwin'
/tmp/ccSwWkgx.o(.text+0x174): undefined reference to `COLS'
/tmp/ccSwWkgx.o(.text+0x17d): undefined reference to `LINES'
/tmp/ccSwWkgx.o(.text+0x186): undefined reference to `newwin'
/tmp/ccSwWkgx.o(.text+0x197): undefined reference to `LINES'
/tmp/ccSwWkgx.o(.text+0x1a2): undefined reference to `newwin'
/tmp/ccSwWkgx.o(.text+0x1bc): undefined reference to `scrollok'
/tmp/ccSwWkgx.o(.text+0x1cf): undefined reference to `acs_map'
/tmp/ccSwWkgx.o(.text+0x1d5): undefined reference to `acs_map'
/tmp/ccSwWkgx.o(.text+0x1db): undefined reference to `acs_map'
/tmp/ccSwWkgx.o(.text+0x1e1): undefined reference to `acs_map'
/tmp/ccSwWkgx.o(.text+0x1ed): undefined reference to `wborder'
/tmp/ccSwWkgx.o(.text+0x1f8): undefined reference to `stdscr'
/tmp/ccSwWkgx.o(.text+0x1fe): undefined reference to `wrefresh'
/tmp/ccSwWkgx.o(.text+0x20f): undefined reference to `wrefresh'
/tmp/ccSwWkgx.o(.text+0x220): undefined reference to `wrefresh'
/tmp/ccSwWkgx.o(.text+0x231): undefined reference to `wrefresh'
/tmp/ccSwWkgx.o(.text+0x239): undefined reference to `doupdate'
collect2: ld returned 1 exit status
-------------
and yes i got my ncurses and curses library installed... i did it like 5 times using slackware ugradepkg....
btw i run slackware 8.1
thx in advance