5

我想在我的一些程序中使用它而不是标准的 IOStream。

此外,NCurses 是否可以在 Windows 上运行,如果可以,会更好吗?

4

3 回答 3

5

下载 zip 文件,将其解压缩到通常放置外部库的任何位置,然后查看自述文件,它会告诉您以下内容:

PDCurses 已被移植到 DOS、OS/2、Win32、X11 和 SDL。每个平台都有一个包含端口特定源文件的目录。构建说明位于每个平台的 README 文件中。

Win32 目录中的自述文件告诉您有几个不同编译器的生成文件。简而言之,您运行make

make -f生成文件名

它提到了您可以设置的几个选项,包括 WIDE 和 UTF8。

然后使用该库,将包含curses.h的目录添加到您的包含路径并与为您生成的pdcurses.lib文件链接make。如何修改包含路径和链接库取决于您的开发环境,并且在很大程度上与 PDCurses 无关。

于 2012-02-15T21:29:45.680 回答
1

在 VSCode 上

[步骤 1] 安装 MinGW :

  • MinGW安装步骤
  • ^(请确保您仔细按照步骤操作)

[步骤 2] 构建 PDCurses:

  • 下载PDCurses-master.zip并提取内容

  • 运行MSYS2 MinGW 64-bit (或MSYS2 MinGW 32-bit^1

  • cd进入wincon文件夹并运行make -f Makefile WIDE=Y DLL=Y

[步骤 3] 复制文件:

如果您到目前为止正确执行了上述步骤,则文件夹内应该有 2 个特定文件,wincon称为pdcurses.apdcurses.dll

  • 重命名pdcurses.alibpdcurses.a
  • 复制pdcurses.dllC:\msys64\mingw64\bin
  • 复制libpdcurses.aC:\msys64\mingw64\lib
  • 复制curses.hpanel.h形成PDCurses-master文件夹到C:\msys64\mingw64\include

[步骤 4] 构建示例:

  • 安装C/C++ 扩展

  • 按照这些步骤在 VSCode 中创建一个工作环境

  • 添加到"-lpdcurses"_"args":tasks.json

  • 你就完成了(至少这些步骤对我有用)

额外的

  • 如果需要,您也可以通过在终端g++ your_example.c -o your_example -lpdcurses内运行来手动构建一个示例[...]MSYS2 MinGW 64-bit
  • ^1如果您想为 32 个系统构建一个好的规则是遵循上述所有步骤,但无论您看到 64 将其替换为 32
  • 演示/示例

事情应该是这样的:

在此处输入图像描述

  • 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
}
  • 启动.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"
        }
    ]
}
  • 任务.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"
}
于 2021-10-19T14:25:45.260 回答
0

我终于成功了。首先根据文档构建/编译源代码。

make -f Makefile # did for me, Windows 10

复制curses.hpanel.h进入您的include文件夹。并且,复制wincon/pdcurses.a到您的lib文件夹中。重命名pdcurses.alibpdcurses.a. (因为这是标准)。

现在,您可以curses.h像这样包含和编译它。

g++ main.cpp -lpdcurses
于 2021-07-29T11:21:43.603 回答