c - `#include <gmpxx.h>` 无法用 `fatal error: iosfwd: No such file or directory` 编译

标签 c linux gcc gmp

我正尝试在我的 C 程序中使用 GMP 库,如下所示:

/* gmp test */
#include <gmpxx.h>

main() {
  printf("yay, it works!\n");
}

我正在 Linux 上用 gcc -o a.out my-c-program.c 编译它,但在编译 #include <gmpxx.h> 时出现此错误上面一行:

gcc -o a.out my-c-program.c
In file included from my-c-program.c:2:0:
/usr/include/gmpxx.h:34:18: fatal error: iosfwd: No such file or directory
compilation terminated.

Compilation exited abnormally with code 1 at Thu May  5 11:34:16

我查看了 gmpxx.h /usr/include/gmpxx.h 下的文件,在第 34 行,有行 #include <iosfwd> ,这解释了错误。但是我该如何解决呢?我错过了图书馆吗?还是我的 gcc 中遗漏了什么?命令?

最佳答案

作为 C 库的 GMP 的正确 header 名称是 gmp.h

gmpxx.h 适用于 GMP 的 C++ Class Interface ,它建立在 gmp.h 之上,需要使用 C++ 编译器(例如 g++)进行编译。

关于c - `#include <gmpxx.h>` 无法用 `fatal error: iosfwd: No such file or directory` 编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37058182/

相关文章:

c++ - 堆与栈之间的距离

macos - Mac 上的汇编和 Linux 上的汇编有什么区别?

c - C语言中定义的 'int'和 'char'类型在哪里?

c - 替换 ioctl() 函数

c++ - 三个数字中的最小值

linux - ALIX 2D13,使用闪存和硬盘的 linux 内核错误 "serial number revalidation"

linux - 如何在以文本模式运行的 Linux 服务器中通过 ssh 启动 vlc-nox?

c - 多线程合并排序无法正确对数组进行排序

C - 强制算术表达式的类型

c++ - 为什么 `-fvisibility-inlines-hidden` 不是默认值?