Qt Creator, ncurses and Linux

This post explains how to configure Qt Creator for ncurses. This tutorial was done with the following software versions:

Ubuntu 14.04 LTS

Qt Creator 3.0.1

Qt 5.2.1

First, install the ncurses package for development :

sudo apt-get install libncurses5-dev

Create a new Qt project, for example a “Qt Console Application” project.
In the .pro file of the project, add the following line to specify to the compiler it has to use the ncurses library:

LIBS += -lncurses

To avoid the following error message : “Error opening terminal: unknown.”, add a variable in the run environment of Qt. Project -> Run -> Run environment -> add. Add a variable named TERM and set it of xterm:

You environment should be ready for ncurses. You can check your configuration with the following code: