1

I use Ubuntu 16.04 and have this code in test.cc:

#include <stdio.h>
#include <ncurses.h>
#include <curses.h>
using namespace std;

int main() {
    initscr();
    printf("hit a key:\n");
    getch();
    endwin();
}

When I want to compile that, I do like this:

$ g++ -lcurses -lncurses -ltinfo test.cc -o test

But I get these errors:

/tmp/ccTyQ9rR.o: In function `main':
test.cc:(.text+0x5): undefined reference to `initscr'
test.cc:(.text+0x16): undefined reference to `stdscr'
test.cc:(.text+0x1e): undefined reference to `wgetch'
test.cc:(.text+0x23): undefined reference to `endwin'
collect2: error: ld returned 1 exit status

How I can solve above problem by using curses.h and without writing function?

Alan Birtles
  • 32,622
  • 4
  • 31
  • 60
hasanghaforian
  • 13,858
  • 11
  • 76
  • 167

0 Answers0