【问题标题】:Code::Blocks, and C++ Compiler problem. cant compile a headerCode::Blocks 和 C++ 编译器问题。无法编译标题
【发布时间】:2020-05-17 16:36:10
【问题描述】:

我在编译 C++ 源代码时遇到问题。该代码是键盘记录器。起初,我用 .cpp 保存,并尝试使用此命令从终端编译它

g++ test.cpp

然后终端向我显示了这条消息

test.cpp:1:10: fatal error: conio.h: No such file or directory
#include <conio.h>
         ^~~~~~~~~
compilation terminated.

还有这条消息

test.cpp:2:10: fatal error: windows.h: No such file or directory
#include <windows.h>
         ^~~~~~~~~~~
compilation terminated.

为了解决这个问题,我尝试使用 C++ IDE,code::blocks。从终端安装,并将键盘记录器源代码复制到 code:::blocks。但 IDE 显示此消息

||=== Build file: Debug in Belajar CPP (compiler: GNU GCC Compiler) ===|
/home/lucky/test.cpp|1|fatal error: conio.h: No such file or directory|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

我只是不知道如何解决这个问题以及如何在线搜索解决方案。因为我是使用 Linux-Mint 的新手。有人可以帮我解决这个问题吗?

【问题讨论】:

  • windows.h linux 上不会有这个头文件。除非你正在使用 mingw 进行交叉编译。
  • conio.h 用于 DOS。也许 Turbo C++
  • 这意味着你可能无法构建你想要的东西。
  • 在 Windows 上构建它或为您使用的任何平台查找键盘记录器。差不多就是这样。我会说移植代码,但我猜这可能超出了您当前的操舵室。
  • 至于“如何在线搜索解决方案”,我在Stack Overflow的搜索框中输入了“conio.h No such file or directory”。

标签: c++ terminal compiler-errors codeblocks linux-mint


【解决方案1】:

首先,conio.h 和 windows.h 这些头文件在 linux 控制台上是不支持的。

替代方案是使用 NCurses 库。它可以完成您可能想要的所有控制台相关内容,并且是 Linux 标准库的一部分(即在每个发行版中都可用)。

改为包含“ncurses.h”。

希望这能解决您的问题。

【讨论】:

  • 它不会解决他的 Windows API 依赖关系。它似乎不是他自己的代码,并且作为“键盘记录器”,必然是特定于平台的。
猜你喜欢
  • 2011-04-14
  • 2012-06-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多