Wednesday, January 5, 2022

[SOLVED] Undefined reference to stdscr

Issue


I want to compile a C code in the latest version of ubuntu. when I do this, I get the following error:
gcc <fileName>.c

/usr/bin/ld: /tmp/ccY8CJ10.o: in function `main':
sudoku.c:(.text+0xb8): undefined reference to `stdscr'
/usr/bin/ld: sudoku.c:(.text+0xc0): undefined reference to `wgetch'
collect2: error: ld returned 1 exit status

Do you have any idea what causes this?
I know the problem is <curses.h> header in my code, but I don't know how to fix it.


Solution

You could use -lcurses. Ex: gcc main.c -o demo -lcurses



Answered By - TechTycho