Curses is cool. It enables us to make cool command-line applications. Consider this demo program:
To develop such programs on Windows, we can use PDCurses library. You can download the latest stable version here. Alternatively, you may also clone the Github repository to get the latest nightly version on this repo.
Download the source and unpack it. You will see a folder called win32
in the unpacked files. Go to that directory. There you will see some files needed for making the library. I am going to assume that you use mingw32, like I do. To build the library, you need to open command prompt and go to this directory, and execute:
mingw32-make -f mingwin32.mak pdcurses.a
After that, you will notice that several files will be generated (such as addch.o
, addchstr.o
, etc.). The one you need is pdcurses.a
. This is the library. To test whether the built library works or not, do the following steps:
- Create a new directory somewhere else. Let’s call it
pdcurs34-test
. - Copy the
pdcurses.a
file here. - Create a new subdirectory here called
include
. This folder will hold all the necessary header files. - Go back to the
pdcurs34
source folder. On the root folder you will see several header files (curses.h
,curspriv.h
,panel.h
, andterm.h
). Copy all of these files to theinclude
folder that you just created. - Finally, copy all of the
.c
files fromdemos
folder to thepdcurs34-test
folder. This is only needed for testing.
The preparation is complete, now to actually test, open command prompt and go to pdcurs34-test
directory. We will try to build one program, the one called worm.c
. To do that, you only need to execute
gcc -o worm worm.c pdcurses.a -I include
And that’s it! If it work successfully, you can see the built program called worm.exe
and run it from your command prompt. Having done this, now you can learn how to build command line programs using C/C++.
Have a nice day!