How to Install PDCurses, ncurses on Windows

⚪ A library identical to ncurses, but for DOS/Windows.


How to Install PDCurses, ncurses on Windows


PDCurses is a text-based user interface library that provides an API compatible with ncurses.

With PDCurses it is possible to develop TUI applications regardless of the platform. It is designed to be used on a variety of operating systems, including Windows, DOS, OS/2, and Unix-like .com/tags#unix).


Dependencies

First of all, you need to have the following tools installed on your Windows:


How to Compile and Install PDCurses on Windows

After all dependencies are satisfied, now let’s clone, compile and install the PDCurses library.

Open Windows Terminal or PowerShell or even CMD and follow the steps.

Tip: The ideal thing to do after opening one of these applications is to enter the Desktop, as we will be sure there will be no permission problems:

cd Desktop

First clone the official repository on GitHub:

git clone https://github.com/wmcbrine/PDCurses

Now enter the cloned PDCurses folder and the wincon subfolder

cd .\PDCurses\wincon

Now just run the make command

As renamed as it can be mingw32-make if you haven’t done so!

make


Install the files

After the compilation is complete, you can still find PDCurses\wincon in: Windows Terminal, PowerShell or CMD. Copy the files to subfolders of C:\mingw64:

Copy the PDCurses static library, run this command:

copy pdcurses.a C:\mingw64\lib\

And also copy the header, but first exit the wincon folder:

CD ..
copy curses.h C:\mingw64\include\

If you wanted, you can even delete the cloned repository: PDCurses\.


Testing a Hello, World!

Having done all the steps correctly, now create a file named main.cpp, or whatever name you prefer in a location you can create (example: on the Desktop) and insert this content:

#include <curses.h>

int main(){
 initscr();
 printw("Hello, PDCurses!");
 refresh();
 getch();
 endwin();

 return 0;
}

To compile, run this command:

g++ -I C:\mingw64\include main.cpp C:\mingw64\lib\pdcurses.a

Indicating the folder path where to find the curses.h file and compile it together with the pdcurses.a file, in some cases it is possible to use only the flag: -lpdcurses, but I believe that in your case it won’t work.

Once compiled, now just run the binary: a.exe or if you are using PowerShell:

.\a.exe

All terminal content will be cleared and the message will appear. Pressing any key will exit this message and return to the terminal!

PDCurses running


For more information about PDCurses I recommend accessing the address: https://github.com/wmcbrine/PDCurses.


windows ncurses tui cpp clanguage


Share


YouTube channel

Subscribe


Marcos Oliveira

Marcos Oliveira

Software developer
https://github.com/terroo