我正尝试在我的 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/