我想在我的一些程序中使用它而不是标准的 IOStream。
此外,NCurses 是否可以在 Windows 上运行,如果可以,会更好吗?
下载 zip 文件,将其解压缩到通常放置外部库的任何位置,然后查看自述文件,它会告诉您以下内容:
PDCurses 已被移植到 DOS、OS/2、Win32、X11 和 SDL。每个平台都有一个包含端口特定源文件的目录。构建说明位于每个平台的 README 文件中。
Win32 目录中的自述文件告诉您有几个不同编译器的生成文件。简而言之,您运行make
:
make -f生成文件名
它提到了您可以设置的几个选项,包括 WIDE 和 UTF8。
然后使用该库,将包含curses.h的目录添加到您的包含路径并与为您生成的pdcurses.lib文件链接make
。如何修改包含路径和链接库取决于您的开发环境,并且在很大程度上与 PDCurses 无关。
下载PDCurses-master.zip并提取内容
运行MSYS2 MinGW 64-bit
(或MSYS2 MinGW 32-bit
^1)
cd
进入wincon
文件夹并运行make -f Makefile WIDE=Y DLL=Y
源
如果您到目前为止正确执行了上述步骤,则文件夹内应该有 2 个特定文件,wincon
称为pdcurses.a
pdcurses.dll
pdcurses.a
为libpdcurses.a
pdcurses.dll
到C:\msys64\mingw64\bin
libpdcurses.a
到C:\msys64\mingw64\lib
curses.h
并panel.h
形成PDCurses-master
文件夹到C:\msys64\mingw64\include
g++ your_example.c -o your_example -lpdcurses
内运行来手动构建一个示例[...]MSYS2 MinGW 64-bit
{
"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
}
{
// 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": [
{
"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"
}
我终于成功了。首先根据文档构建/编译源代码。
make -f Makefile # did for me, Windows 10
复制curses.h
并panel.h
进入您的include
文件夹。并且,复制wincon/pdcurses.a
到您的lib
文件夹中。重命名pdcurses.a
为libpdcurses.a
. (因为这是标准)。
现在,您可以curses.h
像这样包含和编译它。
g++ main.cpp -lpdcurses