Skip to content
Advertisement

How to include or link ncurses/ curses library in Codeblocks 13.12 in Ubuntu 16.04?

Hope you are doing great!

I am using codeblocks 13.12 in my Elementary OS (Loki) which is based on ubuntu 16.04. Recently , I tried to use getch(), getche() function in my C-language coding and to do that i installed ncurses library in my system. When i try to build code, I get two error messages-

  1. Undefined reference to ‘stdscr’
  2. Undefined reference to ‘wgetch’

Here is my sample code:

JavaScript

What is the solution? I know i have to link the library to my source code file in command line.

Here is my command line execution :
gcc -o example_3_1_1test1 example_3_1_1.c -lncurses

complies without error

JavaScript

which is wrong. Because my program don’t take input from keyboard and automatically returns -1.

I want to build/complile my code from codeblocks automatically. So, how can i link ncurses library in codeblocks 13.12?

Thanks in advance.

Nazmul

Advertisement

Answer

setting > complier > search directories

Just click on add

enter image description here

I linked the boost library

enter image description here

and

enter image description here

and
put your -lncurses here as I put -pthread and std=c11

enter image description here

Advertisement