gmp_int Boost errors

gmp_int Boost errors

本文关键字:errors Boost int gmp      更新时间:2023-10-16

下面是我的简单测试代码:

#include <boost/multiprecision/gmp.hpp>
using namespace boost::multiprecision;
int main()
{
    gmp_int v = 1;
    std::cout << v << std::endl;
    return 0;
}

当我尝试构建和运行时,我得到以下错误:

error: there are no arguments to 'mp_get_memory_functions' that depend on a template parameter, so a declaration of 'mp_get_memory_functions' must be available [-fpermissive]
note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
error: 'mp_get_memory_functions' was not declared in this scope
error: 'mpz_combit' was not declared in this scope
error: 'mp_get_memory_functions' was not declared in this scope|
error: invalid conversion from 'int' to 'const __mpz_struct*' [-fpermissive]
error: cannot bind 'std::ostream {aka std::basic_ostream<char>}' lvalue to 'std::basic_ostream<char>&&'
error:   initializing argument 1 of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = boost::multiprecision::backends::gmp_int]'

我正在使用Code::Blocks。我使用了预编译的windows GMP库。在代码::块我有gmpliblibgmp.a在链接器,gmpinclude在编译器目录和gmplib在链接器目录。任何帮助将在GMP的工作受到赞赏。我认为我没有正确安装GMP,但这可能是一个简单的问题。

您忘记使用gmp_int后端类型的数字适配器:

number<gmp_int> v = 1;

查看Live On Coliru:

#include <boost/multiprecision/gmp.hpp>
#include <iostream>
using namespace boost::multiprecision;
int main()
{
    number<gmp_int> v = 1;
    std::cout << v << std::endl;
}

我已经解决了问题。我没有正确链接所有的头文件和库文件