Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I install PDCurses in Windows for use with C++?

Tags:

c++

pdcurses

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?

like image 805
user1212347 Avatar asked Feb 15 '12 20:02

user1212347


2 Answers

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.

like image 107
Rob Kennedy Avatar answered Nov 02 '22 21:11

Rob Kennedy


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

  • Open\Run MSYS2 MinGW 64-bit (or MSYS2 MinGW 32-bit^1)

  • cd into the wincon folder and run make -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 to libpdcurses.a
  • copy pdcurses.dll into C:\msys64\mingw64\bin
  • copy libpdcurses.a into C:\msys64\mingw64\lib
  • copy curses.h and panel.h form PDCurses-master folder into C:\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": into tasks.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 inside MSYS2 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:

enter image description here

  • 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"
}
like image 2
Giorgos Xou Avatar answered Nov 02 '22 20:11

Giorgos Xou