C++ 针对 GNU 多精度库的编译错误

C++ Compilation error against GNU's Multi-precision library

本文关键字:编译 错误 精度 针对 GNU C++      更新时间:2023-10-16

在编译依赖于GNU Multi-precision库的第三方库(称为azove 2.0)时,我得到以下错误:

> make
g++ -Wall -O3 -DFIX_NUMBER_OF_SIGMDDNODE_SONS -DUSE_TIMER -I. -c conBDD.cpp -o conBDD.o
In file included from conBDDnode.hpp:27,
                 from conBDD.hpp:25,
                 from conBDD.cpp:22:
/usr/include/gmpxx.h: In destructor ‘__gmp_alloc_cstring::~__gmp_alloc_cstring()’:
/usr/include/gmpxx.h:2096: error: ‘strlen’ was not declared in this scope
conBDD.cpp: In member function ‘void conBDD::build()’:
conBDD.cpp:61: error: ‘numeric_limits’ was not declared in this scope
conBDD.cpp:61: error: expected primary-expression before ‘int’
conBDD.cpp:61: error: expected `;' before ‘int’
conBDD.cpp:68: error: expected primary-expression before ‘int’
conBDD.cpp:68: error: expected `;' before ‘int’
make: *** [conBDD.o] Error 1

我试过添加以下两行

#include <cstdlib> 
using std::strlen;

conBDD.cpp,但是错误仍然存在。

我不知道这个错误是来自GNU的多精度库还是来自Azove。

我将从分配责任开始。在您的项目中创建一个空的cpp文件,例如test.cpp,并只包含违规的gmpxx.h文件。如果你能编写测试cpp, GMP就脱险了。然后尝试只包含令人不快的azove标头。如果您可以在其他空文件中编译azove头文件,那么azove就脱离了问题,并且您包含/定义的某些内容会干扰它们。一旦你缩小了问题的根源,你就会发现解决问题更容易了。