gmp_int提升错误

时间:2014-08-05 23:10:58

标签: c++ boost codeblocks gmp

这是我的简单测试代码:

#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库。在代码:: Blocks中,链接器中有gmp\lib\libgmp.a,编译器目录中有gmp\include,链接器目录中有gmp\lib。 在获得GMP工作时,我们将不胜感激。我认为我没有正确安装GMP,但这可能是一个简单的问题。

2 个答案:

答案 0 :(得分:2)

您忘记在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;
}

答案 1 :(得分:0)

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