首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >gmp_int Boost误差

gmp_int Boost误差
EN

Stack Overflow用户
提问于 2014-08-05 23:10:58
回答 2查看 362关注 0票数 2

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

代码语言:javascript
复制
#include <boost/multiprecision/gmp.hpp>

using namespace boost::multiprecision;

int main()
{
    gmp_int v = 1;
    std::cout << v << std::endl;

    return 0;
}

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

代码语言:javascript
复制
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]'

我正在使用代码::块。我使用了预编译的windows GMP库。在代码::块中,链接器中有gmp\lib\libgmp.a,编译器目录中有gmp\include,链接器目录中有gmp\lib。任何帮助将不胜感激,以使GMP工作。我认为我没有正确安装GMP,但这可能是一个简单的问题。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-08-08 03:28:25

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

票数 0
EN

Stack Overflow用户

发布于 2014-08-06 00:22:12

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

代码语言:javascript
复制
number<gmp_int> v = 1;

看吧,住在Coliru

代码语言:javascript
复制
#include <boost/multiprecision/gmp.hpp>
#include <iostream>

using namespace boost::multiprecision;

int main()
{
    number<gmp_int> v = 1;
    std::cout << v << std::endl;
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25149781

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档