Teachers ncurses program won't run

Hey guys,

I'm trying to write an ncurses program and the teacher gave us an example file to use so we can see how it works, however, I can't get it to work.

I'd ask my teacher, but I won't be able to get a hold of him until next week and he really isn't that helpful anyway.

Here is the sample code.

I'm using Visual Studio for this and I have not edited his code at all.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
  #include <stdio.h>
#include <curses.h>

int main ( )
{
  char resp;
  int i,j,y,x;
  int width,height;

  initscr();
  getmaxyx(stdscr,height,width);
  clear();

  box(stdscr,'*','-');
  move(1,2);  // goto row 1 column 2
  printw("Print BIG letters");
  move(1,width-10);
  printw("10/13/16");
  /* send stdscr to terminal  */
  refresh();

  cbreak(); // make characters immediately accessible
  noecho(); // don't echo inputs

  move(height-2,2);
  printw("Hit any key to see what happens next:  ");
  getyx(stdscr,y,x);
  move(y,x-2);

  refresh();
  resp = getch();
  // draw big H
  for (i=3; i < 22 ; i++ )
  {
    move(i,15);
    printw("Hello");
    move(i,35);
    printw("Hello");
    if ((10 < i) && (i < 14))
    {
      move(i,20);
      for (j=20; j<35; j+=5)
        printw("Hello");
    }
  }
  refresh();


  move(height-2,2);
  printw("Hit any key to see what happens next:  ");
  getyx(stdscr,y,x);
  move(y,x-2);
  refresh();
  resp = getch();

  // draw big i
  for (i=3; i < 22 ; i++ )
  {
    move(i,55);
    printw("Hello");
    if (((3 <= i) && (i <= 5)) || ((19 <= i) && (i <= 21)))
    {
      move(i,50);
      for (j=50; j<65; j+=5)
        printw("Hello");
    }
  }

  move(height-2,2);
  printw("Hit any key to exit:                   ");
  move(height-2,22);
  resp = getch();

  endwin();

  return 0;
}


There are 15 errors in the code. I can list them all if needed.
> I can list them all if needed.
go ahead, you don't need to ask.
I don't have access to my windows right now but here it is while remote" accessing my mac...

Apple Mach-O Linker (ld) Error
"_box", referenced from:
"_cbreak", referenced from:
"_clear", referenced from:
"_endwin", referenced from:
"_getcurx", referenced from:
"_getcury", referenced from:
"_getmaxx", referenced from:
"_getmaxy", referenced from:
"_initscr", referenced from:
"_move", referenced from:
"_noecho", referenced from:
"_printw", referenced from:
"_refresh", referenced from:
"_stdscr", referenced from:
"_wgetch", referenced from:
Linker command failed with exit code 1 (use -v to see invocation)

I got an email back from my TA (who I might add has not been very helpful during this whole class) asking about the issue and she stated "If you are using IDE, you need to link with -lncurses or -lncurses_g options in your IDE" since I use windows.

I've tried googling this and cannot figure it out. This is my first c++ class and it's just an intro class. The things we've done are for loops, while loops, do/while loops, and switches. Now he wants us to do some weird screen print thing, but instead of telling us how he just said "here is an example of how it works you can use it for reference"

I'm so lost :(
Last edited on
Topic archived. No new replies allowed.