`#include <gmpxx.h>` fails to compile with `fatal error: iosfwd: No such file or directory`
`#include <gmpxx.h>` fails to compile with `fatal error: iosfwd: No such file or directory`
我正尝试在我的 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
我查看了/usr/include/gmpxx.h
下的gmpxx.h
文件,在第34行,有#include <iosfwd>
行,解释了错误。但是我该如何解决呢?我错过了图书馆吗?还是我的 gcc
命令中遗漏了什么?
作为 C 库的 GMP 的正确 header 名称是 gmp.h
。
gmpxx.h
适用于 GMP 的 C++ Class Interface,它建立在 gmp.h
之上,需要使用 C++ 编译器进行编译,例如 g++
.
我正尝试在我的 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
我查看了/usr/include/gmpxx.h
下的gmpxx.h
文件,在第34行,有#include <iosfwd>
行,解释了错误。但是我该如何解决呢?我错过了图书馆吗?还是我的 gcc
命令中遗漏了什么?
作为 C 库的 GMP 的正确 header 名称是 gmp.h
。
gmpxx.h
适用于 GMP 的 C++ Class Interface,它建立在 gmp.h
之上,需要使用 C++ 编译器进行编译,例如 g++
.