How do I install PDCurses in Windows for use with C++?
Solution 1
Download the zip file, unpack it wherever you typically put external libraries, and check the readme, which tells you the following:
PDCurses has been ported to DOS, OS/2, Win32, X11 and SDL. A directory containing the port-specific source files exists for each of these platforms. Build instructions are in the README file for each platform.
The readme file in the Win32 directory tells you that there are makefiles for several different compilers. In short, you run make
:
make -f makefilename
It tells mentions a couple of options you can set, including WIDE and UTF8.
To then use the library, add the directory that contains curses.h to your include path and link with the pdcurses.lib file that make
generates for you. How you modify your include path and your linked libraries depends on your development environment and is largely irrelevant to PDCurses.
Solution 2
On VSCode
[Step 1] Install MinGW :
- MinGW installation steps
- ^(make sure you followed the steps carefully)
[Step 2] BUILD PDCurses:
-
Download PDCurses-master.zip and extract the content
-
Run
MSYS2 MinGW 64-bit
(orMSYS2 MinGW 32-bit
^1) -
cd
into thewincon
folder and runmake -f Makefile WIDE=Y DLL=Y
source
[Step 3] Copy Files:
If you followed the steps above so far correctly, there should be 2 specific files inside wincon
folder called pdcurses.a
and pdcurses.dll
- rename
pdcurses.a
tolibpdcurses.a
- copy
pdcurses.dll
intoC:\msys64\mingw64\bin
- copy
libpdcurses.a
intoC:\msys64\mingw64\lib
- copy
curses.h
andpanel.h
formPDCurses-master
folder intoC:\msys64\mingw64\include
[Step 4] Build an example:
-
Install the C/C++ extension
-
Follow those steps to create a working enviroment inside VSCode
-
Add
"-lpdcurses"
under"args":
intotasks.json
-
and you are Done (at least those steps worked for me)
Extra
- you can also just manually build an example by runing
g++ your_example.c -o your_example -lpdcurses
insideMSYS2 MinGW 64-bit
terminal if you want so [...] - ^1 if you want to build for 32 systems a good rule is to follow all steps above but wherever you see 64 replace it with 32
- demos / examples
how things should look like:
- c_cpp_properties.json
{
"configurations": [
{
"name": "Win64",
"includePath": [
"${default}"
],
"windowsSdkVersion": "10.0.17763.0",
"compilerPath": "C:/msys64/mingw64/bin/g++.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "${default}"
}
],
"version": 4
}
- launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe build active file"
}
]
}
- tasks.json:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\\msys64\\mingw64\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"-lpdcurses"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
user1212347
Updated on June 24, 2022Comments
-
user1212347 about 2 years
I want to use it in some of my programs instead of the standard IOStream.
Also, does NCurses work on Windows, and if so, any better?